Fix the missing pci_disable_device() before return
from tulip_init_one() in the error handling case.
Reported-by: Hulk Robot <[email protected]>
Signed-off-by: Yang Yingliang <[email protected]>
---
drivers/net/ethernet/dec/tulip/tulip_core.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/drivers/net/ethernet/dec/tulip/tulip_core.c b/drivers/net/ethernet/dec/tulip/tulip_core.c
index 79df5a72877b..0040dcaab945 100644
--- a/drivers/net/ethernet/dec/tulip/tulip_core.c
+++ b/drivers/net/ethernet/dec/tulip/tulip_core.c
@@ -1399,8 +1399,10 @@ static int tulip_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
/* alloc_etherdev ensures aligned and zeroed private structures */
dev = alloc_etherdev (sizeof (*tp));
- if (!dev)
+ if (!dev) {
+ pci_disable_device(pdev);
return -ENOMEM;
+ }
SET_NETDEV_DEV(dev, &pdev->dev);
if (pci_resource_len (pdev, 0) < tulip_tbl[chip_idx].io_size) {
@@ -1785,6 +1787,7 @@ static int tulip_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
err_out_free_netdev:
free_netdev (dev);
+ pci_disable_device(pdev);
return -ENODEV;
}
--
2.25.1
On Fri, 06 May 2022 12:11:56 +0200 Rolf Eike Beer wrote:
> Am Freitag, 6. Mai 2022, 11:42:50 CEST schrieb Yang Yingliang:
> > Fix the missing pci_disable_device() before return
> > from tulip_init_one() in the error handling case.
>
> I would suggest removing the pci_disable_device() from tulip_remove_one()
> instead and using pcim_enable_device(), i.e. devres, and let the driver core
> handle all these things. Of course more of the used functions could be
> converted them, e.g. using devm_alloc_etherdev() and so on.
Let's not rewrite the error handling in this dinosaur of a driver
any more than absolutely necessary, please.
Am Freitag, 6. Mai 2022, 11:42:50 CEST schrieb Yang Yingliang:
> Fix the missing pci_disable_device() before return
> from tulip_init_one() in the error handling case.
I would suggest removing the pci_disable_device() from tulip_remove_one()
instead and using pcim_enable_device(), i.e. devres, and let the driver core
handle all these things. Of course more of the used functions could be
converted them, e.g. using devm_alloc_etherdev() and so on.
Eike
Hello:
This patch was applied to netdev/net.git (master)
by Jakub Kicinski <[email protected]>:
On Fri, 6 May 2022 17:42:50 +0800 you wrote:
> Fix the missing pci_disable_device() before return
> from tulip_init_one() in the error handling case.
>
> Reported-by: Hulk Robot <[email protected]>
> Signed-off-by: Yang Yingliang <[email protected]>
> ---
> drivers/net/ethernet/dec/tulip/tulip_core.c | 5 ++++-
> 1 file changed, 4 insertions(+), 1 deletion(-)
Here is the summary with links:
- ethernet: tulip: fix missing pci_disable_device() on error in tulip_init_one()
https://git.kernel.org/netdev/net/c/51ca86b4c9c7
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
Am Freitag, 6. Mai 2022, 18:21:52 CEST schrieb Jakub Kicinski:
> On Fri, 06 May 2022 12:11:56 +0200 Rolf Eike Beer wrote:
> > Am Freitag, 6. Mai 2022, 11:42:50 CEST schrieb Yang Yingliang:
> > > Fix the missing pci_disable_device() before return
> > > from tulip_init_one() in the error handling case.
> >
> > I would suggest removing the pci_disable_device() from tulip_remove_one()
> > instead and using pcim_enable_device(), i.e. devres, and let the driver
> > core handle all these things. Of course more of the used functions could
> > be converted them, e.g. using devm_alloc_etherdev() and so on.
>
> Let's not rewrite the error handling in this dinosaur of a driver
> any more than absolutely necessary, please.
Challenge accepted ;)
[ 274.452394] tulip0: no phy info, aborting mtable build
[ 274.499041] tulip0: MII transceiver #1 config 1000 status 782d advertising 01e1
[ 274.750691] net eth0: Digital DS21142/43 Tulip rev 65 at MMIO 0xf4008000, 00:30:6e:08:7d:21, IRQ 17
[ 283.104520] net eth0: Setting full-duplex based on MII#1 link partner capability of c1e1
Works fine, patch in a minute.