From: Jiri Slaby Date: Wed, 6 Jan 2010 06:54:16 +0000 (+0000) Subject: NET: atlx, fix memory leak X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=2467ab9590092ffdf837e9283e84dedd04c93ab3;p=GitHub%2FLineageOS%2Fandroid_kernel_motorola_exynos9610.git NET: atlx, fix memory leak Stanse found a memory leak in atl2_get_eeprom. eeprom_buff is not freed/assigned on all paths. Fix that. Signed-off-by: Jiri Slaby Cc: Jay Cliburn Cc: Chris Snook Cc: Jie Yang Cc: atl1-devel@lists.sourceforge.net Cc: "David S. Miller" Cc: netdev@vger.kernel.org Signed-off-by: David S. Miller --- diff --git a/drivers/net/atlx/atl2.c b/drivers/net/atlx/atl2.c index c0451d75cdcf..ec52529394ad 100644 --- a/drivers/net/atlx/atl2.c +++ b/drivers/net/atlx/atl2.c @@ -1959,12 +1959,15 @@ static int atl2_get_eeprom(struct net_device *netdev, return -ENOMEM; for (i = first_dword; i < last_dword; i++) { - if (!atl2_read_eeprom(hw, i*4, &(eeprom_buff[i-first_dword]))) - return -EIO; + if (!atl2_read_eeprom(hw, i*4, &(eeprom_buff[i-first_dword]))) { + ret_val = -EIO; + goto free; + } } memcpy(bytes, (u8 *)eeprom_buff + (eeprom->offset & 3), eeprom->len); +free: kfree(eeprom_buff); return ret_val;