1
0
Fork 0

jffs2: Fix memory leak in jffs2_scan_eraseblock() error path

In jffs2_scan_eraseblock(), 'sumptr' is allocated through kmalloc() if
'sumlen' is larger than 'buf_size'. However, it is not deallocated in the
following execution if jffs2_fill_scan_buf() fails, leading to a memory
leak bug. To fix this issue, free 'sumptr' before returning the error.

Signed-off-by: Wenwen Wang <wenwen@cs.uga.edu>
Signed-off-by: Richard Weinberger <richard@nod.at>
alistair/sunxi64-5.4-dsi
Wenwen Wang 2019-08-19 16:55:04 -05:00 committed by Richard Weinberger
parent 61b875e88a
commit 6a379f6745
1 changed files with 4 additions and 1 deletions

View File

@ -527,8 +527,11 @@ static int jffs2_scan_eraseblock (struct jffs2_sb_info *c, struct jffs2_eraseblo
err = jffs2_fill_scan_buf(c, sumptr,
jeb->offset + c->sector_size - sumlen,
sumlen - buf_len);
if (err)
if (err) {
if (sumlen > buf_size)
kfree(sumptr);
return err;
}
}
}