diff options
author | Richard Weinberger <richard@nod.at> | 2015-10-12 23:35:36 +0200 |
---|---|---|
committer | Sasha Levin <alexander.levin@verizon.com> | 2016-11-23 19:58:29 -0500 |
commit | b9ce8700a2e38f36b8814e886ce2e5c8e9fc596f (patch) | |
tree | b54a8af6c93087edbbc87467f09cb98f03875302 /fs/ubifs | |
parent | cad1ca2a9485333c04581c69bbbe52fbd410d9ec (diff) |
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 <richard@nod.at>
Reviewed-by: David Gstir <david@sigma-star.at>
Signed-off-by: Sasha Levin <alexander.levin@verizon.com>
Diffstat (limited to 'fs/ubifs')
-rw-r--r-- | fs/ubifs/dir.c | 5 |
1 files changed, 3 insertions, 2 deletions
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; |