From 3a51540c3ca306053503b7f32befb11313a33c06 Mon Sep 17 00:00:00 2001 From: John Crispin Date: Fri, 17 May 2019 21:29:53 +0200 Subject: [PATCH] iw: fix fd leak inside handle_netns Signed-off-by: John Crispin Signed-off-by: Johannes Berg --- phy.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/phy.c b/phy.c index a4425ea..ba89d46 100644 --- a/phy.c +++ b/phy.c @@ -1,6 +1,7 @@ #include #include #include +#include #include #include #include @@ -531,7 +532,7 @@ static int handle_netns(struct nl80211_state *state, enum id_input id) { char *end; - int fd; + int fd = -1; if (argc < 1 || !*argv[0]) return 1; @@ -559,6 +560,8 @@ static int handle_netns(struct nl80211_state *state, return 1; nla_put_failure: + if (fd >= 0) + close(fd); return -ENOBUFS; } COMMAND(set, netns, "{ | name }", -- 2.39.2