From patchwork Fri May 17 19:29:50 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Crispin X-Patchwork-Id: 10948451 X-Patchwork-Delegate: johannes@sipsolutions.net Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 3EC941395 for ; Fri, 17 May 2019 19:30:33 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3174C283C8 for ; Fri, 17 May 2019 19:30:33 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 25AA12845E; Fri, 17 May 2019 19:30:33 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DA0F3283C8 for ; Fri, 17 May 2019 19:30:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728978AbfEQTa3 (ORCPT ); Fri, 17 May 2019 15:30:29 -0400 Received: from nbd.name ([46.4.11.11]:37368 "EHLO nbd.name" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728951AbfEQTa2 (ORCPT ); Fri, 17 May 2019 15:30:28 -0400 Received: from p548c8c9f.dip0.t-ipconnect.de ([84.140.140.159] helo=bertha.fritz.box) by ds12 with esmtpa (Exim 4.89) (envelope-from ) id 1hRiYk-0006cc-IE; Fri, 17 May 2019 21:30:26 +0200 From: John Crispin To: Johannes Berg Cc: linux-wireless@vger.kernel.org, John Crispin Subject: [PATCH 1/7] iw: fix memory leak inside register_mgmt_frame Date: Fri, 17 May 2019 21:29:50 +0200 Message-Id: <20190517192956.18372-2-john@phrozen.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190517192956.18372-1-john@phrozen.org> References: <20190517192956.18372-1-john@phrozen.org> MIME-Version: 1.0 Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Signed-off-by: John Crispin --- mgmt.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/mgmt.c b/mgmt.c index 60f544b..88fe3fd 100644 --- a/mgmt.c +++ b/mgmt.c @@ -69,9 +69,11 @@ static int register_mgmt_frame(struct nl80211_state *state, NLA_PUT_U16(msg, NL80211_ATTR_FRAME_TYPE, type); NLA_PUT(msg, NL80211_ATTR_FRAME_MATCH, match_len, match); + free(match); return 0; nla_put_failure: + free(match); return -ENOBUFS; } From patchwork Fri May 17 19:29:51 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Crispin X-Patchwork-Id: 10948461 X-Patchwork-Delegate: johannes@sipsolutions.net Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 2E546912 for ; Fri, 17 May 2019 19:30:36 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1FEEC283C5 for ; Fri, 17 May 2019 19:30:36 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 14D642843C; Fri, 17 May 2019 19:30:36 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C638C283C5 for ; Fri, 17 May 2019 19:30:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729050AbfEQTaf (ORCPT ); Fri, 17 May 2019 15:30:35 -0400 Received: from nbd.name ([46.4.11.11]:37374 "EHLO nbd.name" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728954AbfEQTa3 (ORCPT ); Fri, 17 May 2019 15:30:29 -0400 Received: from p548c8c9f.dip0.t-ipconnect.de ([84.140.140.159] helo=bertha.fritz.box) by ds12 with esmtpa (Exim 4.89) (envelope-from ) id 1hRiYk-0006cc-TJ; Fri, 17 May 2019 21:30:27 +0200 From: John Crispin To: Johannes Berg Cc: linux-wireless@vger.kernel.org, John Crispin Subject: [PATCH 2/7] iw: fix endless loop inside handle_mgmt_dump Date: Fri, 17 May 2019 21:29:51 +0200 Message-Id: <20190517192956.18372-3-john@phrozen.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190517192956.18372-1-john@phrozen.org> References: <20190517192956.18372-1-john@phrozen.org> MIME-Version: 1.0 Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP passing -1 will break the while loop further down in the code. Signed-off-by: John Crispin --- mgmt.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/mgmt.c b/mgmt.c index 88fe3fd..338435d 100644 --- a/mgmt.c +++ b/mgmt.c @@ -109,6 +109,8 @@ static int handle_mgmt_dump(struct nl80211_state *state, for (i = 3; i < argc; i += 3) { if (strcmp(argv[i], "count") == 0) { count = 1 + atoi(argv[i + 1]); + if (count < 1) + count = 1; break; } From patchwork Fri May 17 19:29:52 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Crispin X-Patchwork-Id: 10948457 X-Patchwork-Delegate: johannes@sipsolutions.net Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 674FF1395 for ; Fri, 17 May 2019 19:30:34 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5A08726BE9 for ; Fri, 17 May 2019 19:30:34 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4EC4E2843C; Fri, 17 May 2019 19:30:34 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EC95426BE9 for ; Fri, 17 May 2019 19:30:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729041AbfEQTad (ORCPT ); Fri, 17 May 2019 15:30:33 -0400 Received: from nbd.name ([46.4.11.11]:37378 "EHLO nbd.name" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728958AbfEQTa3 (ORCPT ); Fri, 17 May 2019 15:30:29 -0400 Received: from p548c8c9f.dip0.t-ipconnect.de ([84.140.140.159] helo=bertha.fritz.box) by ds12 with esmtpa (Exim 4.89) (envelope-from ) id 1hRiYl-0006cc-Km; Fri, 17 May 2019 21:30:27 +0200 From: John Crispin To: Johannes Berg Cc: linux-wireless@vger.kernel.org, John Crispin Subject: [PATCH 3/7] iw: fix memory leak inside handle_cac Date: Fri, 17 May 2019 21:29:52 +0200 Message-Id: <20190517192956.18372-4-john@phrozen.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190517192956.18372-1-john@phrozen.org> References: <20190517192956.18372-1-john@phrozen.org> MIME-Version: 1.0 Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Signed-off-by: John Crispin --- phy.c | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/phy.c b/phy.c index 77df7a7..a4425ea 100644 --- a/phy.c +++ b/phy.c @@ -328,12 +328,15 @@ static int handle_cac(struct nl80211_state *state, } else if (strcmp(argv[2], "freq") == 0) { err = parse_freqchan(&chandef, false, argc - 3, argv + 3, NULL); } else { - return 1; + err = 1; + goto err_out; } cac_trigger_argv = calloc(argc + 1, sizeof(char*)); - if (!cac_trigger_argv) - return -ENOMEM; + if (!cac_trigger_argv) { + err = -ENOMEM; + goto err_out; + } cac_trigger_argv[0] = argv[0]; cac_trigger_argv[1] = "cac"; @@ -341,9 +344,8 @@ static int handle_cac(struct nl80211_state *state, memcpy(&cac_trigger_argv[3], &argv[2], (argc - 2) * sizeof(char*)); err = handle_cmd(state, id, argc + 1, cac_trigger_argv); - free(cac_trigger_argv); if (err) - return err; + goto err_out; cac_event.ret = 1; cac_event.freq = chandef.control_freq; @@ -357,7 +359,13 @@ static int handle_cac(struct nl80211_state *state, while (cac_event.ret > 0) nl_recvmsgs(state->nl_sock, radar_cb); - return 0; + err = 0; +err_out: + if (radar_cb) + nl_cb_put(radar_cb); + if (cac_trigger_argv) + free(cac_trigger_argv); + return err; } TOPLEVEL(cac, "channel [NOHT|HT20|HT40+|HT40-|5MHz|10MHz|80MHz]\n" "freq [NOHT|HT20|HT40+|HT40-|5MHz|10MHz|80MHz]\n" From patchwork Fri May 17 19:29:53 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Crispin X-Patchwork-Id: 10948447 X-Patchwork-Delegate: johannes@sipsolutions.net Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 280B0912 for ; Fri, 17 May 2019 19:30:32 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 156B828385 for ; Fri, 17 May 2019 19:30:32 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E643A28446; Fri, 17 May 2019 19:30:31 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C7FEB28385 for ; Fri, 17 May 2019 19:30:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729012AbfEQTaa (ORCPT ); Fri, 17 May 2019 15:30:30 -0400 Received: from nbd.name ([46.4.11.11]:37384 "EHLO nbd.name" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728962AbfEQTa3 (ORCPT ); Fri, 17 May 2019 15:30:29 -0400 Received: from p548c8c9f.dip0.t-ipconnect.de ([84.140.140.159] helo=bertha.fritz.box) by ds12 with esmtpa (Exim 4.89) (envelope-from ) id 1hRiYm-0006cc-53; Fri, 17 May 2019 21:30:28 +0200 From: John Crispin To: Johannes Berg Cc: linux-wireless@vger.kernel.org, John Crispin Subject: [PATCH 4/7] iw: fix fd leak inside handle_netns Date: Fri, 17 May 2019 21:29:53 +0200 Message-Id: <20190517192956.18372-5-john@phrozen.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190517192956.18372-1-john@phrozen.org> References: <20190517192956.18372-1-john@phrozen.org> MIME-Version: 1.0 Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Signed-off-by: John Crispin --- 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 }", From patchwork Fri May 17 19:29:54 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Crispin X-Patchwork-Id: 10948459 X-Patchwork-Delegate: johannes@sipsolutions.net Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 81393912 for ; Fri, 17 May 2019 19:30:34 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7137126BE9 for ; Fri, 17 May 2019 19:30:34 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6030E2845E; Fri, 17 May 2019 19:30:34 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 22F53283CA for ; Fri, 17 May 2019 19:30:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729033AbfEQTad (ORCPT ); Fri, 17 May 2019 15:30:33 -0400 Received: from nbd.name ([46.4.11.11]:37390 "EHLO nbd.name" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728970AbfEQTa3 (ORCPT ); Fri, 17 May 2019 15:30:29 -0400 Received: from p548c8c9f.dip0.t-ipconnect.de ([84.140.140.159] helo=bertha.fritz.box) by ds12 with esmtpa (Exim 4.89) (envelope-from ) id 1hRiYm-0006cc-Fu; Fri, 17 May 2019 21:30:28 +0200 From: John Crispin To: Johannes Berg Cc: linux-wireless@vger.kernel.org, John Crispin Subject: [PATCH 5/7] iw: fix memory leak inside parse_sched_scan Date: Fri, 17 May 2019 21:29:54 +0200 Message-Id: <20190517192956.18372-6-john@phrozen.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190517192956.18372-1-john@phrozen.org> References: <20190517192956.18372-1-john@phrozen.org> MIME-Version: 1.0 Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Signed-off-by: John Crispin --- scan.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/scan.c b/scan.c index b0b7828..980bfb4 100644 --- a/scan.c +++ b/scan.c @@ -355,11 +355,12 @@ int parse_sched_scan(struct nl_msg *msg, int *argc, char ***argv) nla_put_failure: if (match) nla_nest_end(msg, match); +out: nlmsg_free(freqs); nlmsg_free(matchset); nlmsg_free(scan_plans); + nlmsg_free(ssids); -out: *argc = c; *argv = v; return err; From patchwork Fri May 17 19:29:55 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Crispin X-Patchwork-Id: 10948449 X-Patchwork-Delegate: johannes@sipsolutions.net Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 75EA31395 for ; Fri, 17 May 2019 19:30:32 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6740C283E7 for ; Fri, 17 May 2019 19:30:32 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 59DC628455; Fri, 17 May 2019 19:30:32 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DF045283E7 for ; Fri, 17 May 2019 19:30:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729021AbfEQTaa (ORCPT ); Fri, 17 May 2019 15:30:30 -0400 Received: from nbd.name ([46.4.11.11]:37398 "EHLO nbd.name" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728951AbfEQTaa (ORCPT ); Fri, 17 May 2019 15:30:30 -0400 Received: from p548c8c9f.dip0.t-ipconnect.de ([84.140.140.159] helo=bertha.fritz.box) by ds12 with esmtpa (Exim 4.89) (envelope-from ) id 1hRiYm-0006cc-PZ; Fri, 17 May 2019 21:30:28 +0200 From: John Crispin To: Johannes Berg Cc: linux-wireless@vger.kernel.org, John Crispin Subject: [PATCH 6/7] iw: fix memory leaks inside handle_scan Date: Fri, 17 May 2019 21:29:55 +0200 Message-Id: <20190517192956.18372-7-john@phrozen.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190517192956.18372-1-john@phrozen.org> References: <20190517192956.18372-1-john@phrozen.org> MIME-Version: 1.0 Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Signed-off-by: John Crispin --- scan.c | 31 +++++++++++++++---------------- 1 file changed, 15 insertions(+), 16 deletions(-) diff --git a/scan.c b/scan.c index 980bfb4..6ad3ad4 100644 --- a/scan.c +++ b/scan.c @@ -389,7 +389,7 @@ static int handle_scan(struct nl80211_state *state, bool passive = false, have_ssids = false, have_freqs = false; bool duration_mandatory = false; size_t ies_len = 0, meshid_len = 0; - unsigned char *ies = NULL, *meshid = NULL, *tmpies; + unsigned char *ies = NULL, *meshid = NULL, *tmpies = NULL; unsigned int flags = 0; ssids = nlmsg_alloc(); @@ -450,7 +450,8 @@ static int handle_scan(struct nl80211_state *state, case DONE: nlmsg_free(ssids); nlmsg_free(freqs); - return 1; + err = 1; + goto nla_put_failure; case FREQ: freq = strtoul(argv[i], &eptr, 10); if (eptr != argv[i] + strlen(argv[i])) { @@ -462,6 +463,8 @@ static int handle_scan(struct nl80211_state *state, NLA_PUT_U32(freqs, i, freq); break; case IES: + if (ies) + free(ies); ies = parse_hex(argv[i], &ies_len); if (!ies) goto nla_put_failure; @@ -490,24 +493,14 @@ static int handle_scan(struct nl80211_state *state, if (ies || meshid) { tmpies = (unsigned char *) malloc(ies_len + meshid_len); - if (!tmpies) { - free(ies); - free(meshid); + if (!tmpies) goto nla_put_failure; - } - if (ies) { + if (ies) memcpy(tmpies, ies, ies_len); - free(ies); - } - if (meshid) { + if (meshid) memcpy(&tmpies[ies_len], meshid, meshid_len); - free(meshid); - } - if (nla_put(msg, NL80211_ATTR_IE, ies_len + meshid_len, tmpies) < 0) { - free(tmpies); + if (nla_put(msg, NL80211_ATTR_IE, ies_len + meshid_len, tmpies) < 0) goto nla_put_failure; - } - free(tmpies); } if (!have_ssids) @@ -535,6 +528,12 @@ static int handle_scan(struct nl80211_state *state, nla_put_failure: nlmsg_free(ssids); nlmsg_free(freqs); + if (meshid) + free(meshid); + if (ies) + free(ies); + if (tmpies) + free(tmpies); return err; } From patchwork Fri May 17 19:29:56 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Crispin X-Patchwork-Id: 10948455 X-Patchwork-Delegate: johannes@sipsolutions.net Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C4960912 for ; Fri, 17 May 2019 19:30:33 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B83B2283CA for ; Fri, 17 May 2019 19:30:33 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id AD04E2843C; Fri, 17 May 2019 19:30:33 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7D2AA283CA for ; Fri, 17 May 2019 19:30:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729026AbfEQTab (ORCPT ); Fri, 17 May 2019 15:30:31 -0400 Received: from nbd.name ([46.4.11.11]:37402 "EHLO nbd.name" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728962AbfEQTaa (ORCPT ); Fri, 17 May 2019 15:30:30 -0400 Received: from p548c8c9f.dip0.t-ipconnect.de ([84.140.140.159] helo=bertha.fritz.box) by ds12 with esmtpa (Exim 4.89) (envelope-from ) id 1hRiYn-0006cc-65; Fri, 17 May 2019 21:30:29 +0200 From: John Crispin To: Johannes Berg Cc: linux-wireless@vger.kernel.org, John Crispin Subject: [PATCH 7/7] iw: fix fp handling inside handle_vendor Date: Fri, 17 May 2019 21:29:56 +0200 Message-Id: <20190517192956.18372-8-john@phrozen.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190517192956.18372-1-john@phrozen.org> References: <20190517192956.18372-1-john@phrozen.org> MIME-Version: 1.0 Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The fp can leak and should not be closed if we do i/o redirection. Signed-off-by: John Crispin --- vendor.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/vendor.c b/vendor.c index 860cd48..d203d85 100644 --- a/vendor.c +++ b/vendor.c @@ -107,7 +107,8 @@ static int handle_vendor(struct nl80211_state *state, if (file) { count = read_file(file, buf, sizeof(buf)); - fclose(file); + if (file != stdin) + fclose(file); } else count = read_hex(argc - 2, &argv[2], buf, sizeof(buf)); @@ -120,6 +121,8 @@ static int handle_vendor(struct nl80211_state *state, return 0; nla_put_failure: + if (file && file != stdin) + fclose(file); return -ENOBUFS; }