Re: [CHECKER] 32 Memory Leaks on Error Paths

From: Chris Wright
Date: Tue Sep 23 2003 - 15:18:55 EST


* David Yu Chen (dychen@xxxxxxxxxxxx) wrote:
> [FILE: 2.6.0-test5/sound/oss/ymfpci.c]
> START -->
> 2530: if ((codec = kmalloc(sizeof(ymfpci_t), GFP_KERNEL)) == NULL) {
> 2531: printk(KERN_ERR "ymfpci: no core\n");
> 2532: return -ENOMEM;
> 2533: }
> 2534: memset(codec, 0, sizeof(*codec));
> 2535:
> ... DELETED 11 lines ...
> 2547: goto out_free;
> 2548: }
> 2549:
> 2550: if ((codec->reg_area_virt = ioremap(base, 0x8000)) == NULL) {
> 2551: printk(KERN_ERR "ymfpci: unable to map registers\n");
> GOTO -->
> 2552: goto out_release_region;
> 2553: }
> 2554:
> 2555: pci_set_master(pcidev);
> 2556:
> 2557: printk(KERN_INFO "ymfpci: %s at 0x%lx IRQ %d\n",
> ... DELETED 78 lines ...
> 2636: out_release_region:
> 2637: release_mem_region(pci_resource_start(pcidev, 0), 0x8000);
> 2638: out_free:
> 2639: if (codec->ac97_codec[0])
> 2640: ac97_release_codec(codec->ac97_codec[0]);
> END -->
> 2641: return -ENODEV;

Yes, this looks like a bug. Patch below. Alan, this look ok?

thanks,
-chris

===== sound/oss/ymfpci.c 1.38 vs edited =====
--- 1.38/sound/oss/ymfpci.c Tue Aug 26 09:25:41 2003
+++ edited/sound/oss/ymfpci.c Tue Sep 23 12:42:45 2003
@@ -2638,6 +2638,7 @@
out_free:
if (codec->ac97_codec[0])
ac97_release_codec(codec->ac97_codec[0]);
+ kfree(codec);
return -ENODEV;
}

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/