From: John W. Linville Date: Wed, 26 Jun 2013 15:07:16 +0000 (-0400) Subject: iw: reorder some code in iw_connect to avoid a potential memory leak X-Git-Tag: v3.11~11 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d8d294c4c23210cd5d2057a95d9bc6b184f308c0;p=thirdparty%2Fiw.git iw: reorder some code in iw_connect to avoid a potential memory leak 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 --- 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";