Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 6a379f67 authored by Wenwen Wang's avatar Wenwen Wang Committed by Richard Weinberger
Browse files

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: default avatarWenwen Wang <wenwen@cs.uga.edu>
Signed-off-by: default avatarRichard Weinberger <richard@nod.at>
parent 61b875e8
Loading
Loading
Loading
Loading
+4 −1
Original line number Diff line number Diff line
@@ -527,10 +527,13 @@ 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;
					}
				}
			}

		}