* [PATCH] qlcnic: fix a memory leak in qlcnic_sriov_set_guest_vlan_mode()
@ 2025-02-28 9:24 Haoxiang Li
2025-03-04 11:28 ` Paolo Abeni
0 siblings, 1 reply; 2+ messages in thread
From: Haoxiang Li @ 2025-02-28 9:24 UTC (permalink / raw)
To: shshaikh, manishc, GR-Linux-NIC-Dev, andrew+netdev, davem,
edumazet, kuba, pabeni, rajesh.borundia, sucheta.chakraborty
Cc: netdev, linux-kernel, Haoxiang Li, stable
Add qlcnic_sriov_free_vlans() to free the memory allocated by
qlcnic_sriov_alloc_vlans() if "sriov->allowed_vlans" fails to
be allocated.
Fixes: 91b7282b613d ("qlcnic: Support VLAN id config.")
Cc: stable@vger.kernel.org
Signed-off-by: Haoxiang Li <haoxiang_li2024@163.com>
---
drivers/net/ethernet/qlogic/qlcnic/qlcnic_sriov_common.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_sriov_common.c b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_sriov_common.c
index f9dd50152b1e..2c01a9ad444f 100644
--- a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_sriov_common.c
+++ b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_sriov_common.c
@@ -454,8 +454,10 @@ static int qlcnic_sriov_set_guest_vlan_mode(struct qlcnic_adapter *adapter,
num_vlans = sriov->num_allowed_vlans;
sriov->allowed_vlans = kcalloc(num_vlans, sizeof(u16), GFP_KERNEL);
- if (!sriov->allowed_vlans)
+ if (!sriov->allowed_vlans) {
+ qlcnic_sriov_free_vlans(adapter);
return -ENOMEM;
+ }
vlans = (u16 *)&cmd->rsp.arg[3];
for (i = 0; i < num_vlans; i++)
--
2.25.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] qlcnic: fix a memory leak in qlcnic_sriov_set_guest_vlan_mode()
2025-02-28 9:24 [PATCH] qlcnic: fix a memory leak in qlcnic_sriov_set_guest_vlan_mode() Haoxiang Li
@ 2025-03-04 11:28 ` Paolo Abeni
0 siblings, 0 replies; 2+ messages in thread
From: Paolo Abeni @ 2025-03-04 11:28 UTC (permalink / raw)
To: Haoxiang Li, shshaikh, manishc, GR-Linux-NIC-Dev, andrew+netdev,
davem, edumazet, kuba, rajesh.borundia, sucheta.chakraborty
Cc: netdev, linux-kernel, stable
On 2/28/25 10:24 AM, Haoxiang Li wrote:
> Add qlcnic_sriov_free_vlans() to free the memory allocated by
> qlcnic_sriov_alloc_vlans() if "sriov->allowed_vlans" fails to
> be allocated.
>
> Fixes: 91b7282b613d ("qlcnic: Support VLAN id config.")
> Cc: stable@vger.kernel.org
> Signed-off-by: Haoxiang Li <haoxiang_li2024@163.com>
AFAICS the fix is not complete: sriov vlans could still be leaked when
qlcnic_sriov_alloc_vlans() fails on any VF with id > 0.
Please handle even such scenario.
Thanks!
Paolo
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2025-03-04 11:28 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-02-28 9:24 [PATCH] qlcnic: fix a memory leak in qlcnic_sriov_set_guest_vlan_mode() Haoxiang Li
2025-03-04 11:28 ` Paolo Abeni
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox