ice: Fix memory leak in ice_get_orom_civd_data()
authorJianglei Nie <niejianglei2021@163.com>
Sat, 2 Apr 2022 02:17:15 +0000 (10:17 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 27 Apr 2022 12:40:59 +0000 (14:40 +0200)
commitc7cde70180fae90cb9136a9302adfb2a8552e612
tree0b17bdceaa954d455b64f49bde9dc5f64055df77
parent91d47fd5d1d93f1d93f72c93c6d7aab772ce7bf3
ice: Fix memory leak in ice_get_orom_civd_data()

[ Upstream commit 7c8881b77908a51814a050da408c89f1a25b7fb7 ]

A memory chunk was allocated for orom_data in ice_get_orom_civd_data()
by vzmalloc(). But when ice_read_flash_module() fails, the allocated
memory is not freed, which will lead to a memory leak.

We can fix it by freeing the orom_data when ce_read_flash_module() fails.

Fixes: af18d8866c80 ("ice: reduce time to read Option ROM CIVD data")
Signed-off-by: Jianglei Nie <niejianglei2021@163.com>
Tested-by: Gurucharan <gurucharanx.g@intel.com> (A Contingent worker at Intel)
Signed-off-by: Tony Nguyen <anthony.l.nguyen@intel.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/net/ethernet/intel/ice/ice_nvm.c