2023-04-18 07:46:29

by RutingZhang

[permalink] [raw]
Subject: [PATCH] net: wwan: iosm: fix a resource leak in probe

drivers/net/wwan/iosm/iosm_ipc_pcie.c:298 ipc_pcie_probe() Smatch warn:
missing unwind goto?
There is a resource leak in this place.

Fix it by changing "return ret" into "goto resources_req_fail".
Fixes: 035e3befc191 ("net: wwan: iosm: fix driver not working with INTEL_IOMMU disabled")

Signed-off-by: Ruting Zhang <[email protected]>
Reviewed-by: Dongliang Mu <[email protected]>
---
The issue is found by static analysis and remains untested.
---
drivers/net/wwan/iosm/iosm_ipc_pcie.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/wwan/iosm/iosm_ipc_pcie.c b/drivers/net/wwan/iosm/iosm_ipc_pcie.c
index 5bf5a93937c9..33339e8af1dc 100644
--- a/drivers/net/wwan/iosm/iosm_ipc_pcie.c
+++ b/drivers/net/wwan/iosm/iosm_ipc_pcie.c
@@ -295,7 +295,7 @@ static int ipc_pcie_probe(struct pci_dev *pci,
ret = dma_set_mask(ipc_pcie->dev, DMA_BIT_MASK(64));
if (ret) {
dev_err(ipc_pcie->dev, "Could not set PCI DMA mask: %d", ret);
- return ret;
+ goto resources_req_fail;
}

ipc_pcie_config_aspm(ipc_pcie);
--
2.34.1


2023-04-19 14:04:55

by Kumar, M Chetan

[permalink] [raw]
Subject: RE: [PATCH] net: wwan: iosm: fix a resource leak in probe

> -----Original Message-----
> From: Ruting Zhang <[email protected]>
> Sent: Tuesday, April 18, 2023 1:09 PM
> To: Kumar, M Chetan <[email protected]>; linuxwwan
> <[email protected]>; Loic Poulain <[email protected]>; Sergey
> Ryazanov <[email protected]>; Johannes Berg
> <[email protected]>; David S. Miller <[email protected]>; Eric
> Dumazet <[email protected]>; Jakub Kicinski <[email protected]>;
> Paolo Abeni <[email protected]>
> Cc: [email protected]; Ruting Zhang
> <[email protected]>; Dongliang Mu <[email protected]>; M
> Chetan Kumar <[email protected]>; [email protected];
> [email protected]
> Subject: [PATCH] net: wwan: iosm: fix a resource leak in probe
>
> drivers/net/wwan/iosm/iosm_ipc_pcie.c:298 ipc_pcie_probe() Smatch warn:
> missing unwind goto?
> There is a resource leak in this place.
>
> Fix it by changing "return ret" into "goto resources_req_fail".
> Fixes: 035e3befc191 ("net: wwan: iosm: fix driver not working with
> INTEL_IOMMU disabled")
>
> Signed-off-by: Ruting Zhang <[email protected]>
> Reviewed-by: Dongliang Mu <[email protected]>
> ---
> The issue is found by static analysis and remains untested.
> ---
> drivers/net/wwan/iosm/iosm_ipc_pcie.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/net/wwan/iosm/iosm_ipc_pcie.c
> b/drivers/net/wwan/iosm/iosm_ipc_pcie.c
> index 5bf5a93937c9..33339e8af1dc 100644
> --- a/drivers/net/wwan/iosm/iosm_ipc_pcie.c
> +++ b/drivers/net/wwan/iosm/iosm_ipc_pcie.c
> @@ -295,7 +295,7 @@ static int ipc_pcie_probe(struct pci_dev *pci,
> ret = dma_set_mask(ipc_pcie->dev, DMA_BIT_MASK(64));
> if (ret) {
> dev_err(ipc_pcie->dev, "Could not set PCI DMA mask: %d",
> ret);
> - return ret;
> + goto resources_req_fail;
> }
>
> ipc_pcie_config_aspm(ipc_pcie);
> --
> 2.34.1

Recently it got fixed and patch is applied to netdev/net.git (main).
Refer to the applied patch [1].

[1]
https://patchwork.kernel.org/project/netdevbpf/patch/[email protected]/