From 341e1a0cf2d8965c8b2f7941a6b2f2c2170df469 Mon Sep 17 00:00:00 2001 From: Artem Bityutskiy Date: Thu, 3 May 2007 11:59:51 +0300 Subject: [PATCH] UBI: fix memory leak in checking code Reported-by: Eric Sesterhenn / Snakebyte Signed-off-by: Artem Bityutskiy --- drivers/mtd/ubi/scan.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/mtd/ubi/scan.c b/drivers/mtd/ubi/scan.c index 473f3200b868..e4456869e753 100644 --- a/drivers/mtd/ubi/scan.c +++ b/drivers/mtd/ubi/scan.c @@ -1310,8 +1310,10 @@ static int paranoid_check_si(const struct ubi_device *ubi, memset(buf, 1, ubi->peb_count); for (pnum = 0; pnum < ubi->peb_count; pnum++) { err = ubi_io_is_bad(ubi, pnum); - if (err < 0) + if (err < 0) { + kfree(buf); return err; + } else if (err) buf[pnum] = 0; } -- 2.30.2