]> 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)
committerJiri Slaby <jslaby@suse.cz>
Sun, 20 Nov 2016 22:06:01 +0000 (23:06 +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: Jiri Slaby <jslaby@suse.cz>
fs/ubifs/dir.c

index 6b4947f75af7a00599c129b2d4e5a97a27222f4a..9bd17a85766748aed67448e06621f50c6063bb1f 100644 (file)
@@ -447,13 +447,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("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;