Re: [PATCH] mtd: fix possible memory leak inlogfs_mtd_can_write_buf()

From: prasad
Date: Sun Sep 02 2012 - 23:54:13 EST


On Sun, Sep 02, 2012 at 10:19:06PM +0800, Wei Yongjun wrote:
> From: Wei Yongjun <yongjun_wei@xxxxxxxxxxxxxxxxx>
>
> 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@xxxxxxxxxxxxxxxxx>
> ---

Applied, Thanks!

> 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;
> }
>
>
>
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/