Skip to contentSkip to conversation

ethernet: tulip: fix missing pci_disable_device() on error in tulip_init_one()

PATCH Applied Yang Yingliang 4 participants 5 messages May 6, 2022 – May 11, 2022

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ethernet: tulip: fix missing pci_disable_device() on error in tulip_init_one()

Fix the missing pci_disable_device() before return from tulip_init_one() in the error handling case.

---
 drivers/net/ethernet/dec/tulip/tulip_core.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/net/ethernet/dec/tulip/tulip_core.c +4 -1
index 79df5a72877b..0040dcaab945 100644
@@ -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;
 }
 
Signature · 1 line
2.25.1
#1 lore raw

Am Freitag, 6. Mai 2022, 11:42:50 CEST schrieb Yang Yingliang:

Quoted 2 lines

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

maintainer
#2 lore raw
Quoted 8 lines · 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:

Quoted 2 lines

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.

#3 lore raw

Am Freitag, 6. Mai 2022, 18:21:52 CEST schrieb Jakub Kicinski:

Quoted 5 lines · On Fri, 06 May 2022 12:11:56 +0200 Rolf Eike Beer wrote:
Quoted 4 lines

Am Freitag, 6. Mai 2022, 11:42:50 CEST schrieb Yang Yingliang:

Quoted 2 lines

Fix the missing pci_disable_device() before return from tulip_init_one() in the error handling case.

Quoted 7 lines
Quoted 4 lines

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.

#4 lore raw
In reply to Yang Yingliang
This patch was applied to netdev/net.git (master) by Jakub Kicinski <[email protected]>:

Hello:

This patch was applied to netdev/net.git (master)
by Jakub Kicinski <[email protected]>:

Quoted 8 lines · 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.

---
 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!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html