netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net v2] qlcnic: fix memory leak in qlcnic_sriov_channel_cfg_cmd()
@ 2025-05-12  4:48 Abdun Nihaal
  2025-05-12 16:57 ` Simon Horman
  2025-05-14  0:30 ` patchwork-bot+netdevbpf
  0 siblings, 2 replies; 3+ messages in thread
From: Abdun Nihaal @ 2025-05-12  4:48 UTC (permalink / raw)
  To: shshaikh
  Cc: Abdun Nihaal, horms, manishc, GR-Linux-NIC-Dev, andrew+netdev,
	davem, edumazet, kuba, pabeni, sucheta.chakraborty,
	rajesh.borundia, netdev, linux-kernel

In one of the error paths in qlcnic_sriov_channel_cfg_cmd(), the memory
allocated in qlcnic_sriov_alloc_bc_mbx_args() for mailbox arguments is
not freed. Fix that by jumping to the error path that frees them, by
calling qlcnic_free_mbx_args(). This was found using static analysis.

Fixes: f197a7aa6288 ("qlcnic: VF-PF communication channel implementation")
Signed-off-by: Abdun Nihaal <abdun.nihaal@gmail.com>
---
This patch is only compile tested. Not tested on real hardware.

V1->V2 : Added information about how the bug was found and how the 
patch was tested, as suggested by Simon Horman.

 drivers/net/ethernet/qlogic/qlcnic/qlcnic_sriov_common.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_sriov_common.c b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_sriov_common.c
index 28d24d59efb8..d57b976b9040 100644
--- a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_sriov_common.c
+++ b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_sriov_common.c
@@ -1484,8 +1484,11 @@ static int qlcnic_sriov_channel_cfg_cmd(struct qlcnic_adapter *adapter, u8 cmd_o
 	}
 
 	cmd_op = (cmd.rsp.arg[0] & 0xff);
-	if (cmd.rsp.arg[0] >> 25 == 2)
-		return 2;
+	if (cmd.rsp.arg[0] >> 25 == 2) {
+		ret = 2;
+		goto out;
+	}
+
 	if (cmd_op == QLCNIC_BC_CMD_CHANNEL_INIT)
 		set_bit(QLC_BC_VF_STATE, &vf->state);
 	else
-- 
2.47.2


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

* Re: [PATCH net v2] qlcnic: fix memory leak in qlcnic_sriov_channel_cfg_cmd()
  2025-05-12  4:48 [PATCH net v2] qlcnic: fix memory leak in qlcnic_sriov_channel_cfg_cmd() Abdun Nihaal
@ 2025-05-12 16:57 ` Simon Horman
  2025-05-14  0:30 ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 3+ messages in thread
From: Simon Horman @ 2025-05-12 16:57 UTC (permalink / raw)
  To: Abdun Nihaal
  Cc: shshaikh, manishc, GR-Linux-NIC-Dev, andrew+netdev, davem,
	edumazet, kuba, pabeni, sucheta.chakraborty, rajesh.borundia,
	netdev, linux-kernel

On Mon, May 12, 2025 at 10:18:27AM +0530, Abdun Nihaal wrote:
> In one of the error paths in qlcnic_sriov_channel_cfg_cmd(), the memory
> allocated in qlcnic_sriov_alloc_bc_mbx_args() for mailbox arguments is
> not freed. Fix that by jumping to the error path that frees them, by
> calling qlcnic_free_mbx_args(). This was found using static analysis.
> 
> Fixes: f197a7aa6288 ("qlcnic: VF-PF communication channel implementation")
> Signed-off-by: Abdun Nihaal <abdun.nihaal@gmail.com>
> ---
> This patch is only compile tested. Not tested on real hardware.
> 
> V1->V2 : Added information about how the bug was found and how the 
> patch was tested, as suggested by Simon Horman.
> 
>  drivers/net/ethernet/qlogic/qlcnic/qlcnic_sriov_common.c | 7 +++++--
>  1 file changed, 5 insertions(+), 2 deletions(-)

Thanks for the update.

Reviewed-by: Simon Horman <horms@kernel.org>


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

* Re: [PATCH net v2] qlcnic: fix memory leak in qlcnic_sriov_channel_cfg_cmd()
  2025-05-12  4:48 [PATCH net v2] qlcnic: fix memory leak in qlcnic_sriov_channel_cfg_cmd() Abdun Nihaal
  2025-05-12 16:57 ` Simon Horman
@ 2025-05-14  0:30 ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+netdevbpf @ 2025-05-14  0:30 UTC (permalink / raw)
  To: Abdun Nihaal
  Cc: shshaikh, horms, manishc, GR-Linux-NIC-Dev, andrew+netdev, davem,
	edumazet, kuba, pabeni, sucheta.chakraborty, rajesh.borundia,
	netdev, linux-kernel

Hello:

This patch was applied to netdev/net.git (main)
by Jakub Kicinski <kuba@kernel.org>:

On Mon, 12 May 2025 10:18:27 +0530 you wrote:
> In one of the error paths in qlcnic_sriov_channel_cfg_cmd(), the memory
> allocated in qlcnic_sriov_alloc_bc_mbx_args() for mailbox arguments is
> not freed. Fix that by jumping to the error path that frees them, by
> calling qlcnic_free_mbx_args(). This was found using static analysis.
> 
> Fixes: f197a7aa6288 ("qlcnic: VF-PF communication channel implementation")
> Signed-off-by: Abdun Nihaal <abdun.nihaal@gmail.com>
> 
> [...]

Here is the summary with links:
  - [net,v2] qlcnic: fix memory leak in qlcnic_sriov_channel_cfg_cmd()
    https://git.kernel.org/netdev/net/c/9d8a99c5a7c7

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



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

end of thread, other threads:[~2025-05-14  0:29 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-05-12  4:48 [PATCH net v2] qlcnic: fix memory leak in qlcnic_sriov_channel_cfg_cmd() Abdun Nihaal
2025-05-12 16:57 ` Simon Horman
2025-05-14  0:30 ` patchwork-bot+netdevbpf

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).