aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Weinberger <richard@nod.at>2015-10-12 23:35:36 +0200
committerMister Oyster <oysterized@gmail.com>2017-04-11 10:58:20 +0200
commitec014b1aa4f5f747f44e7f619bb5522eefadab4b (patch)
treed488851a26a08954c15a354f6643ef9decbe7d51
parentf7c87c9013aa337bf332ec75019ce05486a7c57e (diff)
UBIFS: Fix possible memory leak in ubifs_readdir()
commit aeeb14f763917ccf639a602cfbeee6957fd944a2 upstream. 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: Willy Tarreau <w@1wt.eu>
-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 40d7b9af7..53e82ace6 100644
--- a/fs/ubifs/dir.c
+++ b/fs/ubifs/dir.c
@@ -474,13 +474,14 @@ static int ubifs_readdir(struct file *file, void *dirent, filldir_t filldir)
}
out:
+ kfree(file->private_data);
+ file->private_data = NULL;
+
if (err != -ENOENT) {
ubifs_err("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 */
file->f_pos = 2;
return 0;