]> git.ipfire.org Git - thirdparty/iw.git/commitdiff
iw: Fix memory leak in error path
authorOla Olsson <ola1olsson@gmail.com>
Fri, 9 Oct 2015 14:52:42 +0000 (16:52 +0200)
committerJohannes Berg <johannes.berg@intel.com>
Mon, 12 Oct 2015 07:22:56 +0000 (09:22 +0200)
The leak is present if malloc fails after requesting
a scan with ies or meshid as input.

Signed-off-by: Ola Olsson <ola.olsson@sonymobile.com>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
scan.c

diff --git a/scan.c b/scan.c
index 8197679f8b2e04fc1e138d0241daac58a5123b70..d3c7d98a963d7d7363bcb77ffb2e87ce3c961265 100644 (file)
--- a/scan.c
+++ b/scan.c
@@ -446,8 +446,11 @@ static int handle_scan(struct nl80211_state *state,
 
        if (ies || meshid) {
                tmpies = (unsigned char *) malloc(ies_len + meshid_len);
-               if (!tmpies)
+               if (!tmpies) {
+                       free(ies);
+                       free(meshid);
                        goto nla_put_failure;
+               }
                if (ies) {
                        memcpy(tmpies, ies, ies_len);
                        free(ies);