diff mbox series

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

Message ID 20220506094250.3630615-1-yangyingliang@huawei.com (mailing list archive)
State Accepted
Commit 51ca86b4c9c7c75f5630fa0dbe5f8f0bd98e3c3e
Delegated to: Netdev Maintainers
Headers show
Series ethernet: tulip: fix missing pci_disable_device() on error in tulip_init_one() | expand

Checks

Context Check Description
netdev/fixes_present success Fixes tag not required for -next series
netdev/subject_prefix warning Target tree name not specified in the subject
netdev/cover_letter success Single patches do not need cover letters
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 1 maintainers not CCed: pabeni@redhat.com
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/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 0 this patch: 0
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 18 lines checked
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0
netdev/tree_selection success Guessing tree name failed - patch did not apply

Commit Message

Yang Yingliang May 6, 2022, 9:42 a.m. UTC
Fix the missing pci_disable_device() before return
from tulip_init_one() in the error handling case.

Reported-by: Hulk Robot <hulkci@huawei.com>
Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
---
 drivers/net/ethernet/dec/tulip/tulip_core.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

Comments

Rolf Eike Beer May 6, 2022, 10:11 a.m. UTC | #1
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
Jakub Kicinski May 6, 2022, 4:21 p.m. UTC | #2
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.
patchwork-bot+netdevbpf@kernel.org May 9, 2022, 11:10 p.m. UTC | #3
Hello:

This patch was applied to netdev/net.git (master)
by Jakub Kicinski <kuba@kernel.org>:

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 <hulkci@huawei.com>
> Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
> ---
>  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!
Rolf Eike Beer May 11, 2022, 9:55 p.m. UTC | #4
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.
diff mbox series

Patch

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;
 }