qlcnic: fix memory leak in qlcnic_sriov_channel_cfg_cmd()
Subsystems (3)
PATCH v2 1/1 qlcnic: fix memory leak in qlcnic_sriov_channel_cfg_cmd()
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.
---
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(-)
drivers/net/ethernet/qlogic/qlcnic/qlcnic_sriov_common.c +5 -2
@@ -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
Signature · 1 line
2.47.2
Quoted 7 lines · Abdun Nihaal
In one of the error paths in
qlcnic_sriov_channel_cfg_cmd(), the memory allocated inqlcnic_sriov_alloc_bc_mbx_args()for mailbox arguments is not freed. Fix that by jumping to the error path that frees them, by callingqlcnic_free_mbx_args(). This was found using static analysis.Fixes f197a7aa6288 ("qlcnic: VF-PF communication channel implementation")Signed-off-by Abdun Nihaal <[email protected]>
Quoted 8 lines
---
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.
This patch was applied to netdev/net.git (main) by Jakub Kicinski <[email protected]>:
Hello:
This patch was applied to netdev/net.git (main)
by Jakub Kicinski <[email protected]>:
Quoted 9 lines · 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 inqlcnic_sriov_alloc_bc_mbx_args()for mailbox arguments is not freed. Fix that by jumping to the error path that frees them, by callingqlcnic_free_mbx_args(). This was found using static analysis.Fixes f197a7aa6288 ("qlcnic: VF-PF communication channel implementation")Signed-off-by Abdun Nihaal <[email protected]>[...]
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!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html