Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

staging: wilc1000: fix a couple of memory leaks

The ENOMEM error return paths are not free'ing allocated memory
resulting in a memory leak of allocated structures. Perform the
required kfree to fix the memory leaks.

Issue discovered with static analysis using CoverityScan

Signed-off-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Colin Ian King and committed by
Greg Kroah-Hartman
f54e994c 2e115901

+6 -2
+6 -2
drivers/staging/wilc1000/coreconfigurator.c
··· 338 338 339 339 if (ies_len > 0) { 340 340 network_info->ies = kmemdup(ies, ies_len, GFP_KERNEL); 341 - if (!network_info->ies) 341 + if (!network_info->ies) { 342 + kfree(network_info); 342 343 return -ENOMEM; 344 + } 343 345 } 344 346 network_info->ies_len = ies_len; 345 347 } ··· 375 373 AID_LEN); 376 374 377 375 connect_resp_info->ies = kmemdup(ies, ies_len, GFP_KERNEL); 378 - if (!connect_resp_info->ies) 376 + if (!connect_resp_info->ies) { 377 + kfree(connect_resp_info); 379 378 return -ENOMEM; 379 + } 380 380 381 381 connect_resp_info->ies_len = ies_len; 382 382 }