Skip to contentSkip to conversation

fix memory leak in UBI scanning unit

PATCH In review Jesper Juhl 2 participants 4 messages May 9, 2007 – Jun 17, 2007

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 fix memory leak in UBI scanning unit

In drivers/mtd/ubi/scan.c::paranoid_check_si() there's a memory leak. If the call

	err = ubi_io_is_bad(ubi, pnum);

returns <0, then we'll return with out freeing (and thus leak) buf. This patch eliminates the memory leak by freeing buf before returning.

Problem spotted by the Coverity checker.

Signature · 2 lines
 drivers/mtd/ubi/scan.c |    5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)
drivers/mtd/ubi/scan.c +3 -2
index 473f320..8ff9730 100644
@@ -1310,9 +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)
+		} else if (err)
 			buf[pnum] = 0;
 	}
 
Signature · 3 lines
Jesper Juhl <[email protected]>
Don't top-post  http://www.catb.org/~esr/jargon/html/T/top-post.html
Plain text mails only, please      http://www.expita.com/nomime.html
#1 lore raw
Quoted 7 lines · Jesper Juhl

In drivers/mtd/ubi/scan.c::paranoid_check_si() there's a memory leak. If the call

	err = ubi_io_is_bad(ubi, pnum);

returns <0, then we'll return with out freeing (and thus leak) buf. This patch eliminates the memory leak by freeing buf before returning.

Problem spotted by the Coverity checker.

It was already reported and fixed in our git tree. But thanks anyway.

Signature · 2 lines
Best regards,
Artem Bityutskiy (Битюцкий Артём)
#2 lore raw
Quoted 11 lines · Artem Bityutskiy
Quoted 7 lines · Jesper Juhl

In drivers/mtd/ubi/scan.c::paranoid_check_si() there's a memory leak. If the call

      err = ubi_io_is_bad(ubi, pnum);

returns <0, then we'll return with out freeing (and thus leak) buf. This patch eliminates the memory leak by freeing buf before returning.

Problem spotted by the Coverity checker.

It was already reported and fixed in our git tree. But thanks anyway.

Any idea when you'll be merging with Linus?
I just checked mainline git and the bug is still there :-(

Signature · 3 lines
Jesper Juhl <[email protected]>
Don't top-post  http://www.catb.org/~esr/jargon/html/T/top-post.html
Plain text mails only, please      http://www.expita.com/nomime.html
#3 lore raw
Quoted 2 lines · Jesper Juhl

Any idea when you'll be merging with Linus?
I just checked mainline git and the bug is still there :-(

This bug is in debugging code and is nearly impossible to hit, so it will be merged during the next merge window.

Signature · 2 lines
Best regards,
Artem Bityutskiy (Битюцкий Артём)