Bug 12537

Summary: drivers/net/netxen/netxen_nic_init.c:951: Memory leak: buf
Product: Drivers Reporter: Daniel Marjamäki (danielm77)
Component: NetworkAssignee: Daniel Marjamäki (danielm77)
Status: CLOSED CODE_FIX    
Severity: normal    
Priority: P1    
Hardware: All   
OS: Linux   
Kernel Version: latest git tree Subsystem:
Regression: --- Bisected commit-id:

Description Daniel Marjamäki 2009-01-25 03:06:12 UTC
In the function netxen_pinit_from_rom there is this code...

	buf = kcalloc(n, sizeof(struct crb_addr_pair), GFP_KERNEL);
	if (buf == NULL) {
		printk("%s: netxen_pinit_from_rom: Unable to calloc memory.\n",
				netxen_nic_driver_name);
		return -ENOMEM;
	}
	for (i = 0; i < n; i++) {
		if (netxen_rom_fast_read(adapter, 8*i + 4*offset, &val) != 0 ||
		netxen_rom_fast_read(adapter, 8*i + 4*offset + 4, &addr) != 0)
			return -EIO;

There should be a kfree of buf before the "return -EIO".

This bug was found with cppcheck - http://cppcheck.wiki.sourceforge.net/
Comment 1 Daniel Marjamäki 2009-01-30 02:28:54 UTC
Patch submitted and applied