staging: r8822be: fix memory leak of eeprom_map on error exit return
authorColin Ian King <colin.king@canonical.com>
Wed, 23 Aug 2017 14:34:33 +0000 (15:34 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 28 Aug 2017 08:27:28 +0000 (10:27 +0200)
A memory leak of eeprom_map occurs if the call to halmac_eeprom_parser_88xx
fails. Fix this by kfree'ing it before returning.

Detected by CoverityScan, CID#1454569 ("Resource leak")
Fixes: 938a0447f094 ("staging: r8822be: Add code for halmac sub-driver")

Signed-off-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/rtlwifi/halmac/halmac_88xx/halmac_api_88xx.c

index 0551c471ac43e895d1738e4f86315fac9ebf50dc..f623ae55d1a1cd38cb3bc46d7d64826edc705ff7 100644 (file)
@@ -1950,8 +1950,10 @@ halmac_dump_logical_efuse_map_88xx(struct halmac_adapter *halmac_adapter,
 
                if (halmac_eeprom_parser_88xx(halmac_adapter,
                                              halmac_adapter->hal_efuse_map,
-                                             eeprom_map) != HALMAC_RET_SUCCESS)
+                                             eeprom_map) != HALMAC_RET_SUCCESS) {
+                       kfree(eeprom_map);
                        return HALMAC_RET_EEPROM_PARSING_FAIL;
+               }
 
                PLATFORM_EVENT_INDICATION(
                        driver_adapter, HALMAC_FEATURE_DUMP_LOGICAL_EFUSE,