mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH net] sfc: fix potential memory leak in efx_mae_process_mport()
@ 2025-10-22 16:35 Abdun Nihaal
  2025-10-23 11:27 ` Edward Cree
  0 siblings, 1 reply; 3+ messages in thread
From: Abdun Nihaal @ 2025-10-22 16:35 UTC (permalink / raw)
  To: ecree.xilinx
  Cc: Abdun Nihaal, andrew+netdev, davem, edumazet, kuba, pabeni,
	alejandro.lucero-palau, habetsm.xilinx, netdev,
	linux-net-drivers, linux-kernel

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: a6a15aca4207 ("sfc: enumerate mports in ef100")
Signed-off-by: Abdun Nihaal <nihaal@cse.iitm.ac.in>
---
 drivers/net/ethernet/sfc/mae.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/net/ethernet/sfc/mae.c b/drivers/net/ethernet/sfc/mae.c
index 50f097487b14..15d4af6c1bb9 100644
--- a/drivers/net/ethernet/sfc/mae.c
+++ b/drivers/net/ethernet/sfc/mae.c
@@ -1100,6 +1100,7 @@ static int efx_mae_process_mport(struct efx_nic *efx,
 	if (!IS_ERR_OR_NULL(mport)) {
 		netif_err(efx, drv, efx->net_dev,
 			  "mport with id %u does exist!!!\n", desc->mport_id);
+		kfree(desc);
 		return -EEXIST;
 	}
 
-- 
2.43.0


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH net] sfc: fix potential memory leak in efx_mae_process_mport()
  2025-10-22 16:35 [PATCH net] sfc: fix potential memory leak in efx_mae_process_mport() Abdun Nihaal
@ 2025-10-23 11:27 ` Edward Cree
  2025-10-23 14:08   ` Abdun Nihaal
  0 siblings, 1 reply; 3+ messages in thread
From: Edward Cree @ 2025-10-23 11:27 UTC (permalink / raw)
  To: Abdun Nihaal
  Cc: andrew+netdev, davem, edumazet, kuba, pabeni,
	alejandro.lucero-palau, habetsm.xilinx, netdev,
	linux-net-drivers, linux-kernel

On 22/10/2025 17:35, Abdun Nihaal wrote:
> 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: a6a15aca4207 ("sfc: enumerate mports in ef100")
> Signed-off-by: Abdun Nihaal <nihaal@cse.iitm.ac.in>

Acked-by: Edward Cree <ecree.xilinx@gmail.com>

It might be nice to also add a comment on top of efx_mae_process_mport()
 stating that it takes ownership of @desc from the caller.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH net] sfc: fix potential memory leak in efx_mae_process_mport()
  2025-10-23 11:27 ` Edward Cree
@ 2025-10-23 14:08   ` Abdun Nihaal
  0 siblings, 0 replies; 3+ messages in thread
From: Abdun Nihaal @ 2025-10-23 14:08 UTC (permalink / raw)
  To: Edward Cree
  Cc: andrew+netdev, davem, edumazet, kuba, pabeni,
	alejandro.lucero-palau, habetsm.xilinx, netdev,
	linux-net-drivers, linux-kernel

On Thu, Oct 23, 2025 at 12:27:19PM +0100, Edward Cree wrote:
> Acked-by: Edward Cree <ecree.xilinx@gmail.com>
> 
> It might be nice to also add a comment on top of efx_mae_process_mport()
>  stating that it takes ownership of @desc from the caller.

Sure, I'll add the comment and send a v2 patch.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2025-10-23 14:08 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-10-22 16:35 [PATCH net] sfc: fix potential memory leak in efx_mae_process_mport() Abdun Nihaal
2025-10-23 11:27 ` Edward Cree
2025-10-23 14:08   ` Abdun Nihaal

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®