staging: wilc1000: fix potential memory leak
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>
diff --git a/drivers/staging/wilc1000/linux_mon.c b/drivers/staging/wilc1000/linux_mon.c
index b5db23f..dd80071 100644
--- a/drivers/staging/wilc1000/linux_mon.c
+++ b/drivers/staging/wilc1000/linux_mon.c
@@ -242,6 +242,7 @@
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;
}