linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Staging: bcm: fix possible memory leak in bcm_char_ioctl()
@ 2012-09-03 10:02 Wei Yongjun
  2012-09-04  1:19 ` Kevin McKinney
  0 siblings, 1 reply; 2+ messages in thread
From: Wei Yongjun @ 2012-09-03 10:02 UTC (permalink / raw)
  To: gregkh; +Cc: yongjun_wei, devel, linux-kernel

From: Wei Yongjun <yongjun_wei@trendmicro.com.cn>

psFwInfo has been allocated in this function and should be
freed before leaving from the error handling cases.

spatch with a semantic match is used to found this problem.
(http://coccinelle.lip6.fr/)

Signed-off-by: Wei Yongjun <yongjun_wei@trendmicro.com.cn>
---
 drivers/staging/bcm/Bcmchar.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/staging/bcm/Bcmchar.c b/drivers/staging/bcm/Bcmchar.c
index cf411d1..3d02c2e 100644
--- a/drivers/staging/bcm/Bcmchar.c
+++ b/drivers/staging/bcm/Bcmchar.c
@@ -820,6 +820,7 @@ cntrlEnd:
 
 		if (copy_from_user(psFwInfo, IoBuffer.InputBuffer, IoBuffer.InputLength)) {
 			up(&Adapter->fw_download_sema);
+			kfree(psFwInfo);
 			return -EFAULT;
 		}
 
@@ -829,6 +830,7 @@ cntrlEnd:
 			BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Something else is wrong %lu\n",
 					psFwInfo->u32FirmwareLength);
 			up(&Adapter->fw_download_sema);
+			kfree(psFwInfo);
 			Status = -EINVAL;
 			return Status;
 		}



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2012-09-04  1:19 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-09-03 10:02 [PATCH] Staging: bcm: fix possible memory leak in bcm_char_ioctl() Wei Yongjun
2012-09-04  1:19 ` Kevin McKinney

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).