Skip to content

Commit a230db3

Browse files
richardweinbergergregkh
authored andcommitted
ubifs: Fix memory leak in lprobs self-check
commit eef1981 upstream. Allocate the buffer after we return early. Otherwise memory is being leaked. Cc: <[email protected]> Fixes: 1e51764 ("UBIFS: add new flash file system") Signed-off-by: Richard Weinberger <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 656d6e6 commit a230db3

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

fs/ubifs/lprops.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1091,10 +1091,6 @@ static int scan_check_cb(struct ubifs_info *c,
10911091
}
10921092
}
10931093

1094-
buf = __vmalloc(c->leb_size, GFP_NOFS, PAGE_KERNEL);
1095-
if (!buf)
1096-
return -ENOMEM;
1097-
10981094
/*
10991095
* After an unclean unmount, empty and freeable LEBs
11001096
* may contain garbage - do not scan them.
@@ -1113,6 +1109,10 @@ static int scan_check_cb(struct ubifs_info *c,
11131109
return LPT_SCAN_CONTINUE;
11141110
}
11151111

1112+
buf = __vmalloc(c->leb_size, GFP_NOFS, PAGE_KERNEL);
1113+
if (!buf)
1114+
return -ENOMEM;
1115+
11161116
sleb = ubifs_scan(c, lnum, 0, buf, 0);
11171117
if (IS_ERR(sleb)) {
11181118
ret = PTR_ERR(sleb);

0 commit comments

Comments
 (0)