Bug 10591 - [drivers/net/fs_enet/mii-fec.c]: Memory leaks for new_bus and fec
Summary: [drivers/net/fs_enet/mii-fec.c]: Memory leaks for new_bus and fec
Status: RESOLVED CODE_FIX
Alias: None
Product: Drivers
Classification: Unclassified
Component: Network (show other bugs)
Hardware: All Linux
: P1 normal
Assignee: Jeff Garzik
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-05-02 09:30 UTC by Daniel Marjamäki
Modified: 2008-05-02 12:19 UTC (History)
0 users

See Also:
Kernel Version: 2.6.25.1
Subsystem:
Regression: ---
Bisected commit-id:


Attachments

Description Daniel Marjamäki 2008-05-02 09:30:16 UTC
I think there are some possible memory leaks.

[drivers/net/fs_enet/mii-fec.c:197]: new_bus and fec
[drivers/net/fs_enet/mii-fec.c:306]: new_bus
[drivers/net/fs_enet/mii-fec.c:318]: new_bus and fec


This is the code on lines 181-197 where both new_bus and fec are leaked:

	new_bus = kzalloc(sizeof(struct mii_bus), GFP_KERNEL);
	if (!new_bus)
		goto out;

	fec = kzalloc(sizeof(struct fec_info), GFP_KERNEL);
	if (!fec)
		goto out_mii;

	new_bus->priv = fec;
	new_bus->name = "FEC MII Bus";
	new_bus->read = &fs_enet_fec_mii_read;
	new_bus->write = &fs_enet_fec_mii_write;
	new_bus->reset = &fs_enet_fec_mii_reset;

	ret = of_address_to_resource(ofdev->node, 0, &res);
	if (ret)
		return ret;



This is the code on lines 298-319 where both new_bus and fec are leaked:

	new_bus = kzalloc(sizeof(struct mii_bus), GFP_KERNEL);

	if (NULL == new_bus)
		return -ENOMEM;

	fec = kzalloc(sizeof(struct fec_info), GFP_KERNEL);

	if (NULL == fec)
		return -ENOMEM;

	new_bus->name = "FEC MII Bus",
	new_bus->read = &fs_enet_fec_mii_read,
	new_bus->write = &fs_enet_fec_mii_write,
	new_bus->reset = &fs_enet_fec_mii_reset,
	new_bus->id = pdev->id;

	pdata = (struct fs_mii_fec_platform_info *)pdev->dev.platform_data;

	if (NULL == pdata) {
		printk(KERN_ERR "fs_enet FEC mdio %d: Missing platform data!\n", pdev->id);
		return -ENODEV;
	}

Note You need to log in before you can comment on or make changes to this bug.