]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blame - releases/4.14.69/ubifs-fix-memory-leak-in-lprobs-self-check.patch
4.9-stable patches
[thirdparty/kernel/stable-queue.git] / releases / 4.14.69 / ubifs-fix-memory-leak-in-lprobs-self-check.patch
CommitLineData
69c3e91f
GKH
1From eef19816ada3abd56d9f20c88794cc2fea83ebb2 Mon Sep 17 00:00:00 2001
2From: Richard Weinberger <richard@nod.at>
3Date: Tue, 12 Jun 2018 20:49:45 +0200
4Subject: ubifs: Fix memory leak in lprobs self-check
5
6From: Richard Weinberger <richard@nod.at>
7
8commit eef19816ada3abd56d9f20c88794cc2fea83ebb2 upstream.
9
10Allocate the buffer after we return early.
11Otherwise memory is being leaked.
12
13Cc: <stable@vger.kernel.org>
14Fixes: 1e51764a3c2a ("UBIFS: add new flash file system")
15Signed-off-by: Richard Weinberger <richard@nod.at>
16Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
17
18---
19 fs/ubifs/lprops.c | 8 ++++----
20 1 file changed, 4 insertions(+), 4 deletions(-)
21
22--- a/fs/ubifs/lprops.c
23+++ b/fs/ubifs/lprops.c
24@@ -1091,10 +1091,6 @@ static int scan_check_cb(struct ubifs_in
25 }
26 }
27
28- buf = __vmalloc(c->leb_size, GFP_NOFS, PAGE_KERNEL);
29- if (!buf)
30- return -ENOMEM;
31-
32 /*
33 * After an unclean unmount, empty and freeable LEBs
34 * may contain garbage - do not scan them.
35@@ -1113,6 +1109,10 @@ static int scan_check_cb(struct ubifs_in
36 return LPT_SCAN_CONTINUE;
37 }
38
39+ buf = __vmalloc(c->leb_size, GFP_NOFS, PAGE_KERNEL);
40+ if (!buf)
41+ return -ENOMEM;
42+
43 sleb = ubifs_scan(c, lnum, 0, buf, 0);
44 if (IS_ERR(sleb)) {
45 ret = PTR_ERR(sleb);