]> git.karo-electronics.de Git - linux-beck.git/commitdiff
staging: wilc1000: fix potential memory leak
authorTony Cho <tony.cho@atmel.com>
Mon, 7 Sep 2015 10:09:31 +0000 (19:09 +0900)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sun, 13 Sep 2015 01:24:45 +0000 (18:24 -0700)
This patch adds kfree(mgmt_tx) when memory allocation of mgmt_tx->buff
fails in the second calls of kmalloc() to avoid the memory leak from mgmt_tx
first allocated before the second calls of kmalloc().

Signed-off-by: Tony Cho <tony.cho@atmel.com>
Signed-off-by: Chris Park <chirs.park@atmel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/wilc1000/linux_mon.c
drivers/staging/wilc1000/wilc_wfi_cfgoperations.c

index b5db23ffde6e7115aca7e99d07d8bb7c912e4e16..dd8007141ea609664d469a1242aba6d38bbcf431 100644 (file)
@@ -242,6 +242,7 @@ static int mon_mgmt_tx(struct net_device *dev, const u8 *buf, size_t len)
        mgmt_tx->buff = kmalloc(len, GFP_ATOMIC);
        if (mgmt_tx->buff == NULL) {
                PRINT_ER("Failed to allocate memory for mgmt_tx buff\n");
+               kfree(mgmt_tx);
                return WILC_FAIL;
 
        }
index 663d0f818e4aa011a86409291b1af17782b8e1d9..cf76a337a33688ec7fe36bc53c65ed0454b624cf 100644 (file)
@@ -2533,6 +2533,7 @@ int WILC_WFI_mgmt_tx(struct wiphy *wiphy,
                mgmt_tx->buff = WILC_MALLOC(buf_len);
                if (mgmt_tx->buff == NULL) {
                        PRINT_ER("Failed to allocate memory for mgmt_tx buff\n");
+                       kfree(mgmt_tx);
                        return WILC_FAIL;
                }
                memcpy(mgmt_tx->buff, buf, len);