summaryrefslogtreecommitdiffstats
path: root/fs/ubifs
diff options
context:
space:
mode:
authorRichard Weinberger <richard@nod.at>2015-10-12 23:35:36 +0200
committerRichard Weinberger <richard@nod.at>2015-11-06 23:26:49 +0100
commitaeeb14f763917ccf639a602cfbeee6957fd944a2 (patch)
tree3768507052abd65bff9c0b774ece6a0f0f425832 /fs/ubifs
parent86ba9ed928f33cf6afbac433ff03dd8c6a0ceac4 (diff)
downloadlinux-aeeb14f763917ccf639a602cfbeee6957fd944a2.tar.bz2
UBIFS: Fix possible memory leak in ubifs_readdir()
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>
Diffstat (limited to 'fs/ubifs')
-rw-r--r--fs/ubifs/dir.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/fs/ubifs/dir.c b/fs/ubifs/dir.c
index 1dd9267c165b..a2f9d978b110 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;