NET: atlx, fix memory leak
authorJiri Slaby <[email protected]>
Wed, 6 Jan 2010 06:54:16 +0000 (06:54 +0000)
committerDavid S. Miller <[email protected]>
Thu, 7 Jan 2010 09:07:30 +0000 (01:07 -0800)
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 <[email protected]>
Cc: Jay Cliburn <[email protected]>
Cc: Chris Snook <[email protected]>
Cc: Jie Yang <[email protected]>
Cc: [email protected]
Cc: "David S. Miller" <[email protected]>
Cc: [email protected]
Signed-off-by: David S. Miller <[email protected]>
drivers/net/atlx/atl2.c

index c0451d75cdcf56d52ec5ae9be0ce0f9206aede5d..ec52529394ad27c7f04f1a5a6b0868bd17c1ca6f 100644 (file)
@@ -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;