* [PATCH net] qlcnic: fix memory leak in qlcnic_sriov_channel_cfg_cmd()
@ 2025-05-07 15:21 Abdun Nihaal
2025-05-08 17:36 ` Simon Horman
0 siblings, 1 reply; 3+ messages in thread
From: Abdun Nihaal @ 2025-05-07 15:21 UTC (permalink / raw)
To: shshaikh
Cc: Abdun Nihaal, manishc, GR-Linux-NIC-Dev, andrew+netdev, davem,
edumazet, kuba, pabeni, rajesh.borundia, sucheta.chakraborty,
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().
Fixes: f197a7aa6288 ("qlcnic: VF-PF communication channel implementation")
Signed-off-by: Abdun Nihaal <abdun.nihaal@gmail.com>
---
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] qlcnic: fix memory leak in qlcnic_sriov_channel_cfg_cmd()
2025-05-07 15:21 [PATCH net] qlcnic: fix memory leak in qlcnic_sriov_channel_cfg_cmd() Abdun Nihaal
@ 2025-05-08 17:36 ` Simon Horman
2025-05-11 16:40 ` Abdun Nihaal
0 siblings, 1 reply; 3+ messages in thread
From: Simon Horman @ 2025-05-08 17:36 UTC (permalink / raw)
To: Abdun Nihaal
Cc: shshaikh, manishc, GR-Linux-NIC-Dev, andrew+netdev, davem,
edumazet, kuba, pabeni, rajesh.borundia, sucheta.chakraborty,
netdev, linux-kernel
On Wed, May 07, 2025 at 08:51:00PM +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().
Thanks, I agree with your analysis.
But I think it would be nice to include some text regarding
how you found the bug, e.g. by inspection, using static analysis,
via a crash.
And if you have been able to test the patch on hardware,
or if, rather, it is compile tested only.
>
> Fixes: f197a7aa6288 ("qlcnic: VF-PF communication channel implementation")
> Signed-off-by: Abdun Nihaal <abdun.nihaal@gmail.com>
...
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH net] qlcnic: fix memory leak in qlcnic_sriov_channel_cfg_cmd()
2025-05-08 17:36 ` Simon Horman
@ 2025-05-11 16:40 ` Abdun Nihaal
0 siblings, 0 replies; 3+ messages in thread
From: Abdun Nihaal @ 2025-05-11 16:40 UTC (permalink / raw)
To: Simon Horman
Cc: shshaikh, manishc, GR-Linux-NIC-Dev, andrew+netdev, davem,
edumazet, kuba, pabeni, rajesh.borundia, sucheta.chakraborty,
netdev, linux-kernel
Hello Simon,
On Thu, May 08, 2025 at 06:36:47PM +0100, Simon Horman wrote:
> Thanks, I agree with your analysis.
>
> But I think it would be nice to include some text regarding
> how you found the bug, e.g. by inspection, using static analysis,
> via a crash.
>
> And if you have been able to test the patch on hardware,
> or if, rather, it is compile tested only.
Thanks for your suggestions. I found this using a static analysis tool
that I'm developing as a research prototype. Also the patch was only
compile tested. I'll add both the information when sending the V2 patch.
Regards,
Nihaal
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2025-05-11 16:41 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-05-07 15:21 [PATCH net] qlcnic: fix memory leak in qlcnic_sriov_channel_cfg_cmd() Abdun Nihaal
2025-05-08 17:36 ` Simon Horman
2025-05-11 16:40 ` Abdun Nihaal
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).