]>
Commit | Line | Data |
---|---|---|
69c3e91f GKH |
1 | From eef19816ada3abd56d9f20c88794cc2fea83ebb2 Mon Sep 17 00:00:00 2001 |
2 | From: Richard Weinberger <richard@nod.at> | |
3 | Date: Tue, 12 Jun 2018 20:49:45 +0200 | |
4 | Subject: ubifs: Fix memory leak in lprobs self-check | |
5 | ||
6 | From: Richard Weinberger <richard@nod.at> | |
7 | ||
8 | commit eef19816ada3abd56d9f20c88794cc2fea83ebb2 upstream. | |
9 | ||
10 | Allocate the buffer after we return early. | |
11 | Otherwise memory is being leaked. | |
12 | ||
13 | Cc: <stable@vger.kernel.org> | |
14 | Fixes: 1e51764a3c2a ("UBIFS: add new flash file system") | |
15 | Signed-off-by: Richard Weinberger <richard@nod.at> | |
16 | Signed-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); |