2024-02-27 20:52:32

by Christophe JAILLET

[permalink] [raw]
Subject: [PATCH net 1/2] net: tehuti: Fix a missing pci_disable_msi() in the error handling path of bdx_probe()

If an error occurs after a successful call to pci_enable_msi(),
pci_disable_msi() should be called as already done in the remove function.

Add a new label and the missing pci_disable_msi() call.

Fixes: 1a348ccc1047 ("[NET]: Add Tehuti network driver.")
Signed-off-by: Christophe JAILLET <[email protected]>
---
Compile tested only.
---
drivers/net/ethernet/tehuti/tehuti.c | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/tehuti/tehuti.c b/drivers/net/ethernet/tehuti/tehuti.c
index ca409515ead5..938a5caf5a3b 100644
--- a/drivers/net/ethernet/tehuti/tehuti.c
+++ b/drivers/net/ethernet/tehuti/tehuti.c
@@ -1965,7 +1965,7 @@ bdx_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
ndev = alloc_etherdev(sizeof(struct bdx_priv));
if (!ndev) {
err = -ENOMEM;
- goto err_out_iomap;
+ goto err_out_disable_msi;
}

ndev->netdev_ops = &bdx_netdev_ops;
@@ -2031,7 +2031,7 @@ bdx_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
if (bdx_read_mac(priv)) {
pr_err("load MAC address failed\n");
err = -EFAULT;
- goto err_out_iomap;
+ goto err_out_disable_msi;
}
SET_NETDEV_DEV(ndev, &pdev->dev);
err = register_netdev(ndev);
@@ -2048,6 +2048,11 @@ bdx_probe(struct pci_dev *pdev, const struct pci_device_id *ent)

err_out_free:
free_netdev(ndev);
+err_out_disable_msi:
+#ifdef BDX_MSI
+ if (nic->irq_type == IRQ_MSI)
+ pci_disable_msi(pdev);
+#endif
err_out_iomap:
iounmap(nic->regs);
err_out_res:
--
2.43.2



2024-02-28 12:09:26

by Jiri Pirko

[permalink] [raw]
Subject: Re: [PATCH net 1/2] net: tehuti: Fix a missing pci_disable_msi() in the error handling path of bdx_probe()

Tue, Feb 27, 2024 at 09:50:55PM CET, [email protected] wrote:
>If an error occurs after a successful call to pci_enable_msi(),
>pci_disable_msi() should be called as already done in the remove function.
>
>Add a new label and the missing pci_disable_msi() call.
>
>Fixes: 1a348ccc1047 ("[NET]: Add Tehuti network driver.")
>Signed-off-by: Christophe JAILLET <[email protected]>
>---
>Compile tested only.
>---
> drivers/net/ethernet/tehuti/tehuti.c | 9 +++++++--
> 1 file changed, 7 insertions(+), 2 deletions(-)
>
>diff --git a/drivers/net/ethernet/tehuti/tehuti.c b/drivers/net/ethernet/tehuti/tehuti.c
>index ca409515ead5..938a5caf5a3b 100644
>--- a/drivers/net/ethernet/tehuti/tehuti.c
>+++ b/drivers/net/ethernet/tehuti/tehuti.c
>@@ -1965,7 +1965,7 @@ bdx_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
> ndev = alloc_etherdev(sizeof(struct bdx_priv));
> if (!ndev) {
> err = -ENOMEM;
>- goto err_out_iomap;
>+ goto err_out_disable_msi;
> }
>
> ndev->netdev_ops = &bdx_netdev_ops;
>@@ -2031,7 +2031,7 @@ bdx_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
> if (bdx_read_mac(priv)) {
> pr_err("load MAC address failed\n");
> err = -EFAULT;
>- goto err_out_iomap;
>+ goto err_out_disable_msi;
> }
> SET_NETDEV_DEV(ndev, &pdev->dev);
> err = register_netdev(ndev);
>@@ -2048,6 +2048,11 @@ bdx_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
>
> err_out_free:
> free_netdev(ndev);
>+err_out_disable_msi:
>+#ifdef BDX_MSI

ifdef does not seem to be necessary here. The irq_type check should be
enough.

pw-bot: cr


>+ if (nic->irq_type == IRQ_MSI)
>+ pci_disable_msi(pdev);
>+#endif
> err_out_iomap:
> iounmap(nic->regs);
> err_out_res:
>--
>2.43.2
>
>

2024-02-28 18:08:49

by Christophe JAILLET

[permalink] [raw]
Subject: Re: [PATCH net 1/2] net: tehuti: Fix a missing pci_disable_msi() in the error handling path of bdx_probe()

Le 28/02/2024 à 10:51, Jiri Pirko a écrit :
> Tue, Feb 27, 2024 at 09:50:55PM CET, [email protected] wrote:
>> If an error occurs after a successful call to pci_enable_msi(),
>> pci_disable_msi() should be called as already done in the remove function.
>>
>> Add a new label and the missing pci_disable_msi() call.
>>
>> Fixes: 1a348ccc1047 ("[NET]: Add Tehuti network driver.")
>> Signed-off-by: Christophe JAILLET <[email protected]>
>> ---
>> Compile tested only.
>> ---
>> drivers/net/ethernet/tehuti/tehuti.c | 9 +++++++--
>> 1 file changed, 7 insertions(+), 2 deletions(-)
>>
>> diff --git a/drivers/net/ethernet/tehuti/tehuti.c b/drivers/net/ethernet/tehuti/tehuti.c
>> index ca409515ead5..938a5caf5a3b 100644
>> --- a/drivers/net/ethernet/tehuti/tehuti.c
>> +++ b/drivers/net/ethernet/tehuti/tehuti.c
>> @@ -1965,7 +1965,7 @@ bdx_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
>> ndev = alloc_etherdev(sizeof(struct bdx_priv));
>> if (!ndev) {
>> err = -ENOMEM;
>> - goto err_out_iomap;
>> + goto err_out_disable_msi;
>> }
>>
>> ndev->netdev_ops = &bdx_netdev_ops;
>> @@ -2031,7 +2031,7 @@ bdx_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
>> if (bdx_read_mac(priv)) {
>> pr_err("load MAC address failed\n");
>> err = -EFAULT;
>> - goto err_out_iomap;
>> + goto err_out_disable_msi;
>> }
>> SET_NETDEV_DEV(ndev, &pdev->dev);
>> err = register_netdev(ndev);
>> @@ -2048,6 +2048,11 @@ bdx_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
>>
>> err_out_free:
>> free_netdev(ndev);
>> +err_out_disable_msi:
>> +#ifdef BDX_MSI
>
> ifdef does not seem to be necessary here. The irq_type check should be
> enough.

I thought about removing it, but I left it because it how it is done in
the remove function.

I'll send a v2 without the ifdef and will also add another patch to
remove it as well from the remove function.

CJ

>
> pw-bot: cr
>
>
>> + if (nic->irq_type == IRQ_MSI)
>> + pci_disable_msi(pdev);
>> +#endif
>> err_out_iomap:
>> iounmap(nic->regs);
>> err_out_res:
>> --
>> 2.43.2
>>
>>
>
>