diff mbox series

[iproute2,1/3] ctrl: Fix fd leak in ctrl_listen()

Message ID 20240208172647.324168-1-stephen@networkplumber.org (mailing list archive)
State Accepted
Commit f4dc6a784f6e2cee091027434f05a501f4cc1411
Delegated to: Stephen Hemminger
Headers show
Series [iproute2,1/3] ctrl: Fix fd leak in ctrl_listen() | expand

Checks

Context Check Description
netdev/tree_selection success Not a local patch

Commit Message

Stephen Hemminger Feb. 8, 2024, 5:26 p.m. UTC
From: Maks Mishin <maks.mishinfz@gmail.com>

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 <maks.mishinFZ@gmail.com>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 genl/ctrl.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

Comments

patchwork-bot+netdevbpf@kernel.org Feb. 9, 2024, 4:50 p.m. UTC | #1
Hello:

This series was applied to iproute2/iproute2.git (main)
by Stephen Hemminger <stephen@networkplumber.org>:

On Thu,  8 Feb 2024 09:26:27 -0800 you wrote:
> From: Maks Mishin <maks.mishinfz@gmail.com>
> 
> 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 <maks.mishinFZ@gmail.com>
> Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
> 
> [...]

Here is the summary with links:
  - [iproute2,1/3] ctrl: Fix fd leak in ctrl_listen()
    https://git.kernel.org/pub/scm/network/iproute2/iproute2.git/commit/?id=f4dc6a784f6e
  - [iproute2,2/3] ip: detect errors in netconf monitor mode
    https://git.kernel.org/pub/scm/network/iproute2/iproute2.git/commit/?id=00e8a64dac3b
  - [iproute2,3/3] ip: detect rtnl_listen errors while monitoring netns
    https://git.kernel.org/pub/scm/network/iproute2/iproute2.git/commit/?id=8f340a075138

You are awesome, thank you!
diff mbox series

Patch

diff --git a/genl/ctrl.c b/genl/ctrl.c
index bae73a54bc37..72a9b01302cf 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;
 }