* [PATCH v2] ice: Fix memory leak in ice_get_orom_civd_data()
@ 2022-04-02 2:17 Jianglei Nie
2022-04-14 6:46 ` [Intel-wired-lan] " G, GurucharanX
0 siblings, 1 reply; 2+ messages in thread
From: Jianglei Nie @ 2022-04-02 2:17 UTC (permalink / raw)
To: jesse.brandeburg, anthony.l.nguyen, davem, kuba
Cc: intel-wired-lan, netdev, linux-kernel, Jianglei Nie
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.
Signed-off-by: Jianglei Nie <niejianglei2021@163.com>
---
drivers/net/ethernet/intel/ice/ice_nvm.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/net/ethernet/intel/ice/ice_nvm.c b/drivers/net/ethernet/intel/ice/ice_nvm.c
index 4eb0599714f4..13cdb5ea594d 100644
--- a/drivers/net/ethernet/intel/ice/ice_nvm.c
+++ b/drivers/net/ethernet/intel/ice/ice_nvm.c
@@ -641,6 +641,7 @@ ice_get_orom_civd_data(struct ice_hw *hw, enum ice_bank_select bank,
status = ice_read_flash_module(hw, bank, ICE_SR_1ST_OROM_BANK_PTR, 0,
orom_data, hw->flash.banks.orom_size);
if (status) {
+ vfree(orom_data);
ice_debug(hw, ICE_DBG_NVM, "Unable to read Option ROM data\n");
return status;
}
--
2.25.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* RE: [Intel-wired-lan] [PATCH v2] ice: Fix memory leak in ice_get_orom_civd_data()
2022-04-02 2:17 [PATCH v2] ice: Fix memory leak in ice_get_orom_civd_data() Jianglei Nie
@ 2022-04-14 6:46 ` G, GurucharanX
0 siblings, 0 replies; 2+ messages in thread
From: G, GurucharanX @ 2022-04-14 6:46 UTC (permalink / raw)
To: Jianglei Nie, Brandeburg, Jesse, Nguyen, Anthony L, davem, kuba
Cc: netdev, intel-wired-lan, linux-kernel
> -----Original Message-----
> From: Intel-wired-lan <intel-wired-lan-bounces@osuosl.org> On Behalf Of
> Jianglei Nie
> Sent: Saturday, April 2, 2022 7:47 AM
> To: Brandeburg, Jesse <jesse.brandeburg@intel.com>; Nguyen, Anthony L
> <anthony.l.nguyen@intel.com>; davem@davemloft.net; kuba@kernel.org
> Cc: netdev@vger.kernel.org; intel-wired-lan@lists.osuosl.org; linux-
> kernel@vger.kernel.org; Jianglei Nie <niejianglei2021@163.com>
> Subject: [Intel-wired-lan] [PATCH v2] ice: Fix memory leak in
> ice_get_orom_civd_data()
>
> 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.
>
> Signed-off-by: Jianglei Nie <niejianglei2021@163.com>
> ---
> drivers/net/ethernet/intel/ice/ice_nvm.c | 1 +
> 1 file changed, 1 insertion(+)
>
Tested-by: Gurucharan <gurucharanx.g@intel.com> (A Contingent worker at Intel)
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-04-14 6:47 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-02 2:17 [PATCH v2] ice: Fix memory leak in ice_get_orom_civd_data() Jianglei Nie
2022-04-14 6:46 ` [Intel-wired-lan] " G, GurucharanX
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).