archive mirror
 help / color / mirror / Atom feed
From: Wei Yongjun <>
Subject: [PATCH] Staging: bcm: fix possible memory leak in bcm_char_ioctl()
Date: Mon, 3 Sep 2012 18:02:23 +0800	[thread overview]
Message-ID: <> (raw)

From: Wei Yongjun <>

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.

Signed-off-by: Wei Yongjun <>
 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)) {
+			kfree(psFwInfo);
 			return -EFAULT;
@@ -829,6 +830,7 @@ cntrlEnd:
 			BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Something else is wrong %lu\n",
+			kfree(psFwInfo);
 			Status = -EINVAL;
 			return Status;

             reply	other threads:[~2012-09-03 10:02 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-09-03 10:02 Wei Yongjun [this message]
2012-09-04  1:19 ` Kevin McKinney

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \ \ \ \ \ \ \
    --subject='Re: [PATCH] Staging: bcm: fix possible memory leak in bcm_char_ioctl()' \

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

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).