Linux wireless drivers development
 help / color / mirror / Atom feed
From: "John W. Linville" <linville@tuxdriver.com>
To: johannes@sipsolutions.net
Cc: linux-wireless@vger.kernel.org,
	"John W. Linville" <linville@tuxdriver.com>
Subject: [PATCH] iw: reorder some code in iw_connect to avoid a potential memory leak
Date: Wed, 26 Jun 2013 11:07:16 -0400	[thread overview]
Message-ID: <1372259236-6968-1-git-send-email-linville@tuxdriver.com> (raw)

From: "John W. Linville" <linville@tuxdriver.com>

>From Coverity run on version 3.10:

iw-3.10/connect.c:104:leaked_storage –
	Variable "conn_argv" going out of scope leaks the storage it points to.

Signed-off-by: John W. Linville <linville@tuxdriver.com>
---
 connect.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/connect.c b/connect.c
index 74e4578..fb3b2fe 100644
--- a/connect.c
+++ b/connect.c
@@ -94,15 +94,15 @@ static int iw_connect(struct nl80211_state *state, struct nl_cb *cb,
 		argv++;
 	}
 
+	err = __prepare_listen_events(state);
+	if (err)
+		return err;
+
 	conn_argc = 3 + argc;
 	conn_argv = calloc(conn_argc, sizeof(*conn_argv));
 	if (!conn_argv)
 		return -ENOMEM;
 
-	err = __prepare_listen_events(state);
-	if (err)
-		return err;
-
 	conn_argv[0] = dev;
 	conn_argv[1] = "connect";
 	conn_argv[2] = "establish";
-- 
1.8.1.4


                 reply	other threads:[~2013-06-26 15:15 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1372259236-6968-1-git-send-email-linville@tuxdriver.com \
    --to=linville@tuxdriver.com \
    --cc=johannes@sipsolutions.net \
    --cc=linux-wireless@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox