* [PATCH] fix memory leak in UBI scanning unit
@ 2007-05-09 22:26 Jesper Juhl
2007-05-10 8:09 ` Artem Bityutskiy
0 siblings, 1 reply; 4+ messages in thread
From: Jesper Juhl @ 2007-05-09 22:26 UTC (permalink / raw)
To: linux-kernel; +Cc: dedekind, dedekind, 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.
Signed-off-by: Jesper Juhl <jesper.juhl@gmail.com>
--
drivers/mtd/ubi/scan.c | 5 +++--
1 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/drivers/mtd/ubi/scan.c b/drivers/mtd/ubi/scan.c
index 473f320..8ff9730 100644
--- a/drivers/mtd/ubi/scan.c
+++ b/drivers/mtd/ubi/scan.c
@@ -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;
}
--
Jesper Juhl <jesper.juhl@gmail.com>
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
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] fix memory leak in UBI scanning unit
2007-05-09 22:26 [PATCH] fix memory leak in UBI scanning unit Jesper Juhl
@ 2007-05-10 8:09 ` Artem Bityutskiy
2007-06-12 22:21 ` Jesper Juhl
0 siblings, 1 reply; 4+ messages in thread
From: Artem Bityutskiy @ 2007-05-10 8:09 UTC (permalink / raw)
To: Jesper Juhl; +Cc: linux-kernel, dedekind
On Thu, 2007-05-10 at 00:26 +0200, Jesper Juhl wrote:
> 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.
--
Best regards,
Artem Bityutskiy (Битюцкий Артём)
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] fix memory leak in UBI scanning unit
2007-05-10 8:09 ` Artem Bityutskiy
@ 2007-06-12 22:21 ` Jesper Juhl
2007-06-17 11:26 ` Artem Bityutskiy
0 siblings, 1 reply; 4+ messages in thread
From: Jesper Juhl @ 2007-06-12 22:21 UTC (permalink / raw)
To: dedekind; +Cc: linux-kernel, dedekind
On 10/05/07, Artem Bityutskiy <dedekind@infradead.org> wrote:
> On Thu, 2007-05-10 at 00:26 +0200, Jesper Juhl wrote:
> > 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 :-(
--
Jesper Juhl <jesper.juhl@gmail.com>
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
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] fix memory leak in UBI scanning unit
2007-06-12 22:21 ` Jesper Juhl
@ 2007-06-17 11:26 ` Artem Bityutskiy
0 siblings, 0 replies; 4+ messages in thread
From: Artem Bityutskiy @ 2007-06-17 11:26 UTC (permalink / raw)
To: Jesper Juhl; +Cc: linux-kernel
On Wed, 2007-06-13 at 00:21 +0200, Jesper Juhl wrote:
> 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.
--
Best regards,
Artem Bityutskiy (Битюцкий Артём)
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2007-06-17 11:26 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-05-09 22:26 [PATCH] fix memory leak in UBI scanning unit Jesper Juhl
2007-05-10 8:09 ` Artem Bityutskiy
2007-06-12 22:21 ` Jesper Juhl
2007-06-17 11:26 ` Artem Bityutskiy
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox