Skip to content

Commit 46a499a

Browse files
Abdun Nihaalkuba-moo
authored andcommitted
sfc: fix potential memory leak in efx_mae_process_mport()
In efx_mae_enumerate_mports(), memory allocated for mae_mport_desc is passed as a argument to efx_mae_process_mport(), but when the error path in efx_mae_process_mport() gets executed, the memory allocated for desc gets leaked. Fix that by freeing the memory allocation before returning error. Fixes: a6a15ac ("sfc: enumerate mports in ef100") Acked-by: Edward Cree <ecree.xilinx@gmail.com> Signed-off-by: Abdun Nihaal <nihaal@cse.iitm.ac.in> Link: https://patch.msgid.link/20251023141844.25847-1-nihaal@cse.iitm.ac.in Signed-off-by: Jakub Kicinski <kuba@kernel.org>
1 parent 03ca7c8 commit 46a499a

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

  • drivers/net/ethernet/sfc

drivers/net/ethernet/sfc/mae.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1090,6 +1090,9 @@ void efx_mae_remove_mport(void *desc, void *arg)
10901090
kfree(mport);
10911091
}
10921092

1093+
/*
1094+
* Takes ownership of @desc, even if it returns an error
1095+
*/
10931096
static int efx_mae_process_mport(struct efx_nic *efx,
10941097
struct mae_mport_desc *desc)
10951098
{
@@ -1100,6 +1103,7 @@ static int efx_mae_process_mport(struct efx_nic *efx,
11001103
if (!IS_ERR_OR_NULL(mport)) {
11011104
netif_err(efx, drv, efx->net_dev,
11021105
"mport with id %u does exist!!!\n", desc->mport_id);
1106+
kfree(desc);
11031107
return -EEXIST;
11041108
}
11051109

0 commit comments

Comments
 (0)