]> git.ipfire.org Git - thirdparty/iw.git/commitdiff
iw: reorder some code in iw_connect to avoid a potential memory leak
authorJohn W. Linville <linville@tuxdriver.com>
Wed, 26 Jun 2013 15:07:16 +0000 (11:07 -0400)
committerJohannes Berg <johannes.berg@intel.com>
Wed, 26 Jun 2013 15:22:12 +0000 (17:22 +0200)
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

index 74e457859faaf0fe69edc048070641bb69031c9a..fb3b2fe2fc1cb8137a129eea10e42ac89bd20e98 100644 (file)
--- 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";