Commit 341e1a0cf2d8965c8b2f7941a6b2f2c2170df469
1 parent
cb32da0416
Exists in
master
and in
20 other branches
UBI: fix memory leak in checking code
Reported-by: Eric Sesterhenn / Snakebyte <snakebyte@gmx.de> Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
Showing 1 changed file with 3 additions and 1 deletions Side-by-side Diff
drivers/mtd/ubi/scan.c
... | ... | @@ -1310,8 +1310,10 @@ |
1310 | 1310 | memset(buf, 1, ubi->peb_count); |
1311 | 1311 | for (pnum = 0; pnum < ubi->peb_count; pnum++) { |
1312 | 1312 | err = ubi_io_is_bad(ubi, pnum); |
1313 | - if (err < 0) | |
1313 | + if (err < 0) { | |
1314 | + kfree(buf); | |
1314 | 1315 | return err; |
1316 | + } | |
1315 | 1317 | else if (err) |
1316 | 1318 | buf[pnum] = 0; |
1317 | 1319 | } |