]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
UBIFS: Fix possible memory leak in ubifs_readdir()
authorRichard Weinberger <richard@nod.at>
Mon, 12 Oct 2015 21:35:36 +0000 (23:35 +0200)
committerWilly Tarreau <w@1wt.eu>
Fri, 10 Feb 2017 10:03:27 +0000 (11:03 +0100)
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>
fs/ubifs/dir.c

index 605af512aec28f5bda2886903aafecf7c88b7ea6..879242b1f9f06705df1879c518c8a67e1435c3da 100644 (file)
@@ -467,13 +467,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;