public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] mtd: fix possible memory leak in logfs_mtd_can_write_buf()
@ 2012-09-02 14:19 Wei Yongjun
  2012-09-03  3:53 ` prasad
  0 siblings, 1 reply; 2+ messages in thread
From: Wei Yongjun @ 2012-09-02 14:19 UTC (permalink / raw)
  To: joern, prasadjoshi.linux; +Cc: yongjun_wei, logfs, linux-kernel

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

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

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>
---
 fs/logfs/dev_mtd.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/logfs/dev_mtd.c b/fs/logfs/dev_mtd.c
index 9c50144..427bb73 100644
--- a/fs/logfs/dev_mtd.c
+++ b/fs/logfs/dev_mtd.c
@@ -245,8 +245,8 @@ static int logfs_mtd_can_write_buf(struct super_block *sb, u64 ofs)
 		goto out;
 	if (memchr_inv(buf, 0xff, super->s_writesize))
 		err = -EIO;
-	kfree(buf);
 out:
+	kfree(buf);
 	return err;
 }
 



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

end of thread, other threads:[~2012-09-03  3:53 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-09-02 14:19 [PATCH] mtd: fix possible memory leak in logfs_mtd_can_write_buf() Wei Yongjun
2012-09-03  3:53 ` prasad

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox