From: John Crispin Date: Fri, 17 May 2019 19:29:53 +0000 (+0200) Subject: iw: fix fd leak inside handle_netns X-Git-Tag: v5.3~15 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=3a51540c3ca306053503b7f32befb11313a33c06;p=thirdparty%2Fiw.git iw: fix fd leak inside handle_netns Signed-off-by: John Crispin Signed-off-by: Johannes Berg --- 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 }",