From f4dc6a784f6e2cee091027434f05a501f4cc1411 Mon Sep 17 00:00:00 2001 From: Maks Mishin Date: Wed, 7 Feb 2024 02:54:16 +0300 Subject: [PATCH] ctrl: Fix fd leak in ctrl_listen() Use the same pattern for handling rtnl_listen() errors that is used across other iproute2 commands. All other commands exit with status of 2 if rtnl_listen fails. Reported-off-by: Maks Mishin Signed-off-by: Stephen Hemminger --- genl/ctrl.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/genl/ctrl.c b/genl/ctrl.c index bae73a54..72a9b013 100644 --- a/genl/ctrl.c +++ b/genl/ctrl.c @@ -334,8 +334,9 @@ static int ctrl_listen(int argc, char **argv) } if (rtnl_listen(&rth, print_ctrl, (void *) stdout) < 0) - return -1; - + exit(2); + + rtnl_close(&rth); return 0; }