Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1245171 > unrolled thread
| Started by | Richard Weinberger <richard@nod.at> |
|---|---|
| First post | 2015-10-12 23:40 +0200 |
| Last post | 2015-10-13 09:00 +0200 |
| Articles | 2 — 2 participants |
Back to article view | Back to linux.kernel
[PATCH] UBIFS: Fix possible memory leak in ubifs_readdir() Richard Weinberger <richard@nod.at> - 2015-10-12 23:40 +0200
Re: [PATCH] UBIFS: Fix possible memory leak in ubifs_readdir() David Gstir <david@sigma-star.at> - 2015-10-13 09:00 +0200
| From | Richard Weinberger <richard@nod.at> |
|---|---|
| Date | 2015-10-12 23:40 +0200 |
| Subject | [PATCH] UBIFS: Fix possible memory leak in ubifs_readdir() |
| Message-ID | <qiSZ4-2WA-13@gated-at.bofh.it> |
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
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [next] | [standalone]
| From | David Gstir <david@sigma-star.at> |
|---|---|
| Date | 2015-10-13 09:00 +0200 |
| Message-ID | <qj1IZ-7bO-3@gated-at.bofh.it> |
| In reply to | #1245171 |
> 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--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web