Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit aeeb14f7 authored by Richard Weinberger's avatar Richard Weinberger
Browse files

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: default avatarRichard Weinberger <richard@nod.at>
Reviewed-by: default avatarDavid Gstir <david@sigma-star.at>
parent 86ba9ed9
Loading
Loading
Loading
Loading
+3 −2
Original line number Diff line number Diff line
@@ -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;