igb: Fix memory leak in igb_get_module_eeprom()
authorChristian Engelmayer <cengelma@gmx.at>
Fri, 21 Mar 2014 10:25:30 +0000 (03:25 -0700)
committerJeff Kirsher <jeffrey.t.kirsher@intel.com>
Fri, 21 Mar 2014 10:25:30 +0000 (03:25 -0700)
Fix a memory leak in the igb_get_module_eeprom() error handling path.
Detected by Coverity: CID 1016508.

Signed-off-by: Christian Engelmayer <cengelma@gmx.at>
Tested-by: Jeff Pieper <jeffrey.e.pieper@intel.com>
Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
drivers/net/ethernet/intel/igb/igb_ethtool.c

index e35bc1faa452ca9e0200b1227617459b9f99a448..d5c3e6572f2f70009ada16a0428d8bbae7f68575 100644 (file)
@@ -2791,9 +2791,11 @@ static int igb_get_module_eeprom(struct net_device *netdev,
        /* Read EEPROM block, SFF-8079/SFF-8472, word at a time */
        for (i = 0; i < last_word - first_word + 1; i++) {
                status = igb_read_phy_reg_i2c(hw, first_word + i, &dataword[i]);
-               if (status != E1000_SUCCESS)
+               if (status != E1000_SUCCESS) {
                        /* Error occurred while reading module */
+                       kfree(dataword);
                        return -EIO;
+               }
 
                be16_to_cpus(&dataword[i]);
        }