Skip to content

Commit eef1981

Browse files
ubifs: Fix memory leak in lprobs self-check
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]>
1 parent 2567747 commit eef1981

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
@@ -1089,10 +1089,6 @@ static int scan_check_cb(struct ubifs_info *c,
10891089
}
10901090
}
10911091

1092-
buf = __vmalloc(c->leb_size, GFP_NOFS, PAGE_KERNEL);
1093-
if (!buf)
1094-
return -ENOMEM;
1095-
10961092
/*
10971093
* After an unclean unmount, empty and freeable LEBs
10981094
* may contain garbage - do not scan them.
@@ -1111,6 +1107,10 @@ static int scan_check_cb(struct ubifs_info *c,
11111107
return LPT_SCAN_CONTINUE;
11121108
}
11131109

1110+
buf = __vmalloc(c->leb_size, GFP_NOFS, PAGE_KERNEL);
1111+
if (!buf)
1112+
return -ENOMEM;
1113+
11141114
sleb = ubifs_scan(c, lnum, 0, buf, 0);
11151115
if (IS_ERR(sleb)) {
11161116
ret = PTR_ERR(sleb);

0 commit comments

Comments
 (0)