* [PATCH] UBIFS: Fix possible memory leak in ubifs_readdir()
@ 2015-10-12 21:35 Richard Weinberger
2015-10-13 6:50 ` David Gstir
0 siblings, 1 reply; 2+ messages in thread
From: Richard Weinberger @ 2015-10-12 21:35 UTC (permalink / raw)
To: linux-mtd; +Cc: linux-kernel, dedekind1, Richard Weinberger
If ubifs_tnc_next_ent() returns something else than -ENOENT
we leak file->private_data.
Signed-off-by: Richard Weinberger <richard@nod.at>
---
fs/ubifs/dir.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/fs/ubifs/dir.c b/fs/ubifs/dir.c
index 5c27c66..cb88ea3 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;
--
2.5.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] UBIFS: Fix possible memory leak in ubifs_readdir()
2015-10-12 21:35 [PATCH] UBIFS: Fix possible memory leak in ubifs_readdir() Richard Weinberger
@ 2015-10-13 6:50 ` David Gstir
0 siblings, 0 replies; 2+ messages in thread
From: David Gstir @ 2015-10-13 6:50 UTC (permalink / raw)
To: Richard Weinberger; +Cc: linux-mtd, linux-kernel, dedekind1
> On 12.10.2015, at 23:35, Richard Weinberger <richard@nod.at> wrote:
>
> If ubifs_tnc_next_ent() returns something else than -ENOENT
> we leak file->private_data.
>
> Signed-off-by: Richard Weinberger <richard@nod.at>
> ---
> fs/ubifs/dir.c | 5 +++--
> 1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/fs/ubifs/dir.c b/fs/ubifs/dir.c
> index 5c27c66..cb88ea3 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;
> --
> 2.5.0
Looks good to me.
Reviewed-by: David Gstir <david@sigma-star.at>
Thanks,
David
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2015-10-13 6:50 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-10-12 21:35 [PATCH] UBIFS: Fix possible memory leak in ubifs_readdir() Richard Weinberger
2015-10-13 6:50 ` David Gstir
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).