diff options
author | Richard Weinberger <richard@nod.at> | 2018-06-12 20:49:45 +0200 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2018-09-09 19:56:00 +0200 |
commit | a230db38a9fd9b422bb7f114da9bb7141c87fded (patch) | |
tree | e23da3d471926beef7f62ecfc64d884e3a8c3df6 | |
parent | 656d6e6f6d235fe3e349a331ec2d8c5105df721e (diff) | |
download | linux-stable-a230db38a9fd9b422bb7f114da9bb7141c87fded.tar.gz linux-stable-a230db38a9fd9b422bb7f114da9bb7141c87fded.tar.bz2 linux-stable-a230db38a9fd9b422bb7f114da9bb7141c87fded.zip |
ubifs: Fix memory leak in lprobs self-check
commit eef19816ada3abd56d9f20c88794cc2fea83ebb2 upstream.
Allocate the buffer after we return early.
Otherwise memory is being leaked.
Cc: <stable@vger.kernel.org>
Fixes: 1e51764a3c2a ("UBIFS: add new flash file system")
Signed-off-by: Richard Weinberger <richard@nod.at>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r-- | fs/ubifs/lprops.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/fs/ubifs/lprops.c b/fs/ubifs/lprops.c index 6c3a1abd0e22..780a436d8c45 100644 --- a/fs/ubifs/lprops.c +++ b/fs/ubifs/lprops.c @@ -1091,10 +1091,6 @@ static int scan_check_cb(struct ubifs_info *c, } } - buf = __vmalloc(c->leb_size, GFP_NOFS, PAGE_KERNEL); - if (!buf) - return -ENOMEM; - /* * After an unclean unmount, empty and freeable LEBs * may contain garbage - do not scan them. @@ -1113,6 +1109,10 @@ static int scan_check_cb(struct ubifs_info *c, return LPT_SCAN_CONTINUE; } + buf = __vmalloc(c->leb_size, GFP_NOFS, PAGE_KERNEL); + if (!buf) + return -ENOMEM; + sleb = ubifs_scan(c, lnum, 0, buf, 0); if (IS_ERR(sleb)) { ret = PTR_ERR(sleb); |