2015-08-05 14:05:36

by Jia-Ju Bai

[permalink] [raw]
Subject: [PATCH] igb: Fix a memory leak in igb_probe

In error handling code of igb_probe, the memory adapter->shadow_vfta
allocated by kcalloc in igb_sw_init is not freed. So when register_netdev
or igb_init_i2c is failed, a memory leak will occur.
This patch adds kfree to fix it.

Signed-off-by: Jia-Ju Bai <[email protected]>
---
drivers/net/ethernet/intel/igb/igb_main.c | 1 +
1 file changed, 1 insertion(+)

diff --git a/drivers/net/ethernet/intel/igb/igb_main.c b/drivers/net/ethernet/intel/igb/igb_main.c
index 2f70a9b..3efb757 100644
--- a/drivers/net/ethernet/intel/igb/igb_main.c
+++ b/drivers/net/ethernet/intel/igb/igb_main.c
@@ -2645,6 +2645,7 @@ err_eeprom:
if (hw->flash_address)
iounmap(hw->flash_address);
err_sw_init:
+ kfree(adapter->shadow_vfta);
igb_clear_interrupt_scheme(adapter);
pci_iounmap(pdev, hw->hw_addr);
err_ioremap:
--
1.7.9.5


2015-08-11 02:13:52

by Brown, Aaron F

[permalink] [raw]
Subject: RE: [PATCH] igb: Fix a memory leak in igb_probe

> From: [email protected] [mailto:[email protected]]
> On Behalf Of Jia-Ju Bai
> Sent: Wednesday, August 05, 2015 7:05 AM
> To: Kirsher, Jeffrey T; Brandeburg, Jesse
> Cc: [email protected]; [email protected]; linux-
> [email protected]; Jia-Ju Bai
> Subject: [PATCH] igb: Fix a memory leak in igb_probe
>
> In error handling code of igb_probe, the memory adapter->shadow_vfta
> allocated by kcalloc in igb_sw_init is not freed. So when register_netdev
> or igb_init_i2c is failed, a memory leak will occur.
> This patch adds kfree to fix it.
>
> Signed-off-by: Jia-Ju Bai <[email protected]>
> ---
> drivers/net/ethernet/intel/igb/igb_main.c | 1 +
> 1 file changed, 1 insertion(+)

Tested-by: Aaron Brown <[email protected]>