Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

staging: r8822be: fix memory leak of eeprom_map on error exit return

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>

authored by

Colin Ian King and committed by
Greg Kroah-Hartman
2ffabf50 faff950c

+3 -1
+3 -1
drivers/staging/rtlwifi/halmac/halmac_88xx/halmac_api_88xx.c
··· 1950 1950 1951 1951 if (halmac_eeprom_parser_88xx(halmac_adapter, 1952 1952 halmac_adapter->hal_efuse_map, 1953 - eeprom_map) != HALMAC_RET_SUCCESS) 1953 + eeprom_map) != HALMAC_RET_SUCCESS) { 1954 + kfree(eeprom_map); 1954 1955 return HALMAC_RET_EEPROM_PARSING_FAIL; 1956 + } 1955 1957 1956 1958 PLATFORM_EVENT_INDICATION( 1957 1959 driver_adapter, HALMAC_FEATURE_DUMP_LOGICAL_EFUSE,