[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-Id: <1376930196-21785-2-git-send-email-andi@etezian.org>
Date: Mon, 19 Aug 2013 18:36:36 +0200
From: Andi Shyti <andi@...zian.org>
To: josh.h.morris@...ibm.com, pjk1939@...ux.vnet.ibm.com
Cc: linux-kernel@...r.kernel.org, andi@...zian.org
Subject: [PATCH v2 1/1] rsxx: core: fix memory leak
Free 'buf' before returning.
the 'rsxx_cram_write()' function returns twice without freeing
the allocated buffer 'buf' causing a possible memory leak.
This issue has been reported by scan.coverity.com
Signed-off-by: Andi Shyti <andi@...zian.org>
---
drivers/block/rsxx/core.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/drivers/block/rsxx/core.c b/drivers/block/rsxx/core.c
index 6e85e21..fa3740b 100644
--- a/drivers/block/rsxx/core.c
+++ b/drivers/block/rsxx/core.c
@@ -224,19 +224,20 @@ static ssize_t rsxx_cram_write(struct file *fp, const char __user *ubuf,
st = copy_from_user(buf, ubuf, cnt);
if (st)
- return st;
+ goto exit;
info->f_pos = (u32)*ppos + info->offset;
st = rsxx_creg_write(card, CREG_ADD_CRAM + info->f_pos, cnt, buf, 1);
if (st)
- return st;
+ goto exit;
info->offset += cnt;
+exit:
kfree(buf);
- return cnt;
+ return st ? st : cnt;
}
static int rsxx_cram_open(struct inode *inode, struct file *file)
--
1.8.4.rc2
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists