diff mbox series

ctrl: Fix fd leak in ctrl_listen()

Message ID 20240206235416.18086-1-maks.mishinFZ@gmail.com (mailing list archive)
State Superseded
Delegated to: Stephen Hemminger
Headers show
Series ctrl: Fix fd leak in ctrl_listen() | expand

Checks

Context Check Description
netdev/tree_selection success Not a local patch

Commit Message

Maks Mishin Feb. 6, 2024, 11:54 p.m. UTC
Signed-off-by: Maks Mishin <maks.mishinFZ@gmail.com>
---
 genl/ctrl.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/genl/ctrl.c b/genl/ctrl.c
index aff922a4..783c3591 100644
--- a/genl/ctrl.c
+++ b/genl/ctrl.c
@@ -333,8 +333,10 @@  static int ctrl_listen(int argc, char **argv)
 		return -1;
 	}
 
-	if (rtnl_listen(&rth, print_ctrl, (void *) stdout) < 0)
+	if (rtnl_listen(&rth, print_ctrl, (void *) stdout) < 0) {
+		rtnl_close(&rth);
 		return -1;
+	}
 
 	return 0;
 }