diff mbox series

[net,1/3] stmmac: dwmac-loongson: fix missing pci_disable_msi() while module exiting

Message ID 20221105121840.3654266-2-yangyingliang@huawei.com (mailing list archive)
State Superseded
Delegated to: Netdev Maintainers
Headers show
Series stmmac: dwmac-loongson: fixes three leaks | expand

Checks

Context Check Description
netdev/tree_selection success Clearly marked for net
netdev/fixes_present success Fixes tag present in non-next series
netdev/subject_prefix success Link
netdev/cover_letter success Series has a cover letter
netdev/patch_count success Link
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 0 this patch: 0
netdev/cc_maintainers warning 5 maintainers not CCed: pabeni@redhat.com mcoquelin.stm32@gmail.com linux-stm32@st-md-mailman.stormreply.com edumazet@google.com linux-arm-kernel@lists.infradead.org
netdev/build_clang success Errors and warnings before: 0 this patch: 0
netdev/module_param success Was 0 now: 0
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success Fixes tag looks correct
netdev/build_allmodconfig_warn success Errors and warnings before: 0 this patch: 0
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 23 lines checked
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Yang Yingliang Nov. 5, 2022, 12:18 p.m. UTC
pci_enable_msi() has been called in loongson_dwmac_probe(),
so pci_disable_msi() needs be called in remove path and error
path of probe().

Fixes: 30bba69d7db4 ("stmmac: pci: Add dwmac support for Loongson")
Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
---
 drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

Comments

Paolo Abeni Nov. 8, 2022, 10:50 a.m. UTC | #1
Hello,

On Sat, 2022-11-05 at 20:18 +0800, Yang Yingliang wrote:
> pci_enable_msi() has been called in loongson_dwmac_probe(),
> so pci_disable_msi() needs be called in remove path and error
> path of probe().
> 
> Fixes: 30bba69d7db4 ("stmmac: pci: Add dwmac support for Loongson")
> Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
> ---
>  drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c | 11 ++++++++++-
>  1 file changed, 10 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c
> index 79fa7870563b..dd292e71687b 100644
> --- a/drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c
> +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c
> @@ -139,7 +139,15 @@ static int loongson_dwmac_probe(struct pci_dev *pdev, const struct pci_device_id
>  		ret = -ENODEV;
>  	}
>  
> -	return stmmac_dvr_probe(&pdev->dev, plat, &res);
> +	ret = stmmac_dvr_probe(&pdev->dev, plat, &res);
> +	if (ret)
> +		goto err_disable_msi;
> +
> +	return ret;
> +
> +err_disable_msi:
> +	pci_disable_msi(pdev);
> +	return ret;
>  }

It looks like this patch is missing a couple of error paths, still
after pci_enable_msi(), which need 'goto err_disable_msi', too:

https://elixir.bootlin.com/linux/v6.1-rc4/source/drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c#L127
https://elixir.bootlin.com/linux/v6.1-rc4/source/drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c#L139

Cheers,

Paolo
diff mbox series

Patch

diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c
index 79fa7870563b..dd292e71687b 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c
@@ -139,7 +139,15 @@  static int loongson_dwmac_probe(struct pci_dev *pdev, const struct pci_device_id
 		ret = -ENODEV;
 	}
 
-	return stmmac_dvr_probe(&pdev->dev, plat, &res);
+	ret = stmmac_dvr_probe(&pdev->dev, plat, &res);
+	if (ret)
+		goto err_disable_msi;
+
+	return ret;
+
+err_disable_msi:
+	pci_disable_msi(pdev);
+	return ret;
 }
 
 static void loongson_dwmac_remove(struct pci_dev *pdev)
@@ -155,6 +163,7 @@  static void loongson_dwmac_remove(struct pci_dev *pdev)
 		break;
 	}
 
+	pci_disable_msi(pdev);
 	pci_disable_device(pdev);
 }