lkml.org 
[lkml]   [2003]   [Sep]   [16]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
SubjectRe: [CHECKER] 32 Memory Leaks on Error Paths
On Tue, 16 September 2003 08:55:53 +0200, Jörn Engel wrote:
> On Mon, 15 September 2003 21:35:46 -0700, David Yu Chen wrote:
> >
> > looks like checking for mtdblks instead of mtdblk
> > [FILE: 2.6.0-test5/drivers/mtd/mtdblock.c]
> > [FUNC: mtdblock_open]
> > [LINES: 277-279]
> > [VAR: mtdblk]
> > 272: mtdblks[dev]->count++;
> > 273: return 0;
> > 274: }
> > 275:
> > 276: /* OK, it's not open. Create cache info for it */
> > START -->
> > 277: mtdblk = kmalloc(sizeof(struct mtdblk_dev), GFP_KERNEL);
> > 278: if (!mtdblks)
> > END -->
> > 279: return -ENOMEM;
> > 280:
> > 281: memset(mtdblk, 0, sizeof(*mtdblk));
> > 282: mtdblk->count = 1;
> > 283: mtdblk->mtd = mtd;
> > 284:
>
> Invalid. This is quite an obvious false positive, at least if your
> algorithm checks for possible value ranges.

Actually, it *is* valid, as Wade pointed out to me.

David, please apply!

Jörn

--
Mundie uses a textbook tactic of manipulation: start with some
reasonable talk, and lead the audience to an unreasonable conclusion.
-- Bruce Perens

--- linux-2.6.0-test3/drivers/mtd/mtdblock.c~mtdblock_leak 2003-07-05 23:59:30.000000000 +0200
+++ linux-2.6.0-test3/drivers/mtd/mtdblock.c 2003-09-16 10:47:58.000000000 +0200
@@ -275,7 +275,7 @@

/* OK, it's not open. Create cache info for it */
mtdblk = kmalloc(sizeof(struct mtdblk_dev), GFP_KERNEL);
- if (!mtdblks)
+ if (!mtdblk)
return -ENOMEM;

memset(mtdblk, 0, sizeof(*mtdblk));
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
\
 
 \ /
  Last update: 2005-03-22 13:48    [W:0.196 / U:0.044 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site