From: Richard Weinberger Date: Mon, 12 Oct 2015 21:35:36 +0000 (+0200) Subject: UBIFS: Fix possible memory leak in ubifs_readdir() X-Git-Tag: v3.10.105~147 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d414505f516ba5af6ef5699a1cc702591bce0d9f;p=thirdparty%2Fkernel%2Fstable.git 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 Reviewed-by: David Gstir Signed-off-by: Willy Tarreau --- diff --git a/fs/ubifs/dir.c b/fs/ubifs/dir.c index 605af512aec28..879242b1f9f06 100644 --- a/fs/ubifs/dir.c +++ b/fs/ubifs/dir.c @@ -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;