From: Richard Weinberger Date: Mon, 12 Oct 2015 21:35:36 +0000 (+0200) Subject: UBIFS: Fix possible memory leak in ubifs_readdir() X-Git-Tag: v4.1.36~51 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=b9ce8700a2e38f36b8814e886ce2e5c8e9fc596f;p=platform%2Fkernel%2Flinux-exynos.git UBIFS: Fix possible memory leak in ubifs_readdir() [ Upstream commit aeeb14f763917ccf639a602cfbeee6957fd944a2 ] If ubifs_tnc_next_ent() returns something else than -ENOENT we leak file->private_data. Signed-off-by: Richard Weinberger Reviewed-by: David Gstir Signed-off-by: Sasha Levin --- diff --git a/fs/ubifs/dir.c b/fs/ubifs/dir.c index 27060fc855d4..4af40ed5e795 100644 --- a/fs/ubifs/dir.c +++ b/fs/ubifs/dir.c @@ -449,13 +449,14 @@ static int ubifs_readdir(struct file *file, struct dir_context *ctx) } out: + kfree(file->private_data); + file->private_data = NULL; + if (err != -ENOENT) { ubifs_err(c, "cannot find next direntry, error %d", err); return err; } - kfree(file->private_data); - file->private_data = NULL; /* 2 is a special value indicating that there are no more direntries */ ctx->pos = 2; return 0;