netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Randy.Dunlap" <rddunlap@osdl.org>
To: jgarzik@pobox.com
Cc: netdev@oss.sgi.com
Subject: [PATCH] janitor: insert missing iounmap(), add error handling
Date: Fri, 3 Oct 2003 21:29:04 -0700	[thread overview]
Message-ID: <20031003212904.34d4ca01.rddunlap@osdl.org> (raw)


Hi,
Please apply to 2.6.0-test6-current.

Thanks,
--
~Randy



From: Leann Ogasawara <ogasawara@osdl.org>
Subject: Re: [Kernel-janitors] [PATCH] insert missing iounmap()

> > Patch inserts a missing iounmap().  Implements a cleanup path
> > for error handling as well.  Feedback is much appreciated.  Thanks :)



===== drivers/net/natsemi.c 1.55 vs edited =====


 linux-260-test6-kj1-rddunlap/drivers/net/natsemi.c |   39 ++++++++++-----------
 1 files changed, 20 insertions(+), 19 deletions(-)

diff -puN drivers/net/natsemi.c~net_natsemi_iounmap drivers/net/natsemi.c
--- linux-260-test6-kj1/drivers/net/natsemi.c~net_natsemi_iounmap	2003-09-29 17:37:59.000000000 -0700
+++ linux-260-test6-kj1-rddunlap/drivers/net/natsemi.c	2003-09-29 17:37:59.000000000 -0700
@@ -765,19 +765,13 @@ static int __devinit natsemi_probe1 (str
 	SET_NETDEV_DEV(dev, &pdev->dev);
 
 	i = pci_request_regions(pdev, dev->name);
-	if (i) {
-		free_netdev(dev);
-		return i;
-	}
+	if (i)
+		goto err_pci_request_regions;
 
-	{
-		void *mmio = ioremap (ioaddr, iosize);
-		if (!mmio) {
-			pci_release_regions(pdev);
-			free_netdev(dev);
-			return -ENOMEM;
-		}
-		ioaddr = (unsigned long) mmio;
+	ioaddr = (unsigned long) ioremap (ioaddr, iosize);
+	if (!ioaddr) {
+		i = -ENOMEM;
+		goto err_ioremap;
 	}
 
 	/* Work around the dropped serial bit. */
@@ -835,13 +829,9 @@ static int __devinit natsemi_probe1 (str
 		dev->mtu = mtu;
 
 	i = register_netdev(dev);
-	if (i) {
-		pci_release_regions(pdev);
-		unregister_netdev(dev);
-		free_netdev(dev);
-		pci_set_drvdata(pdev, NULL);
-		return i;
-	}
+	if (i)
+		goto err_register_netdev;
+
 	netif_carrier_off(dev);
 
 	if (netif_msg_drv(np)) {
@@ -878,6 +868,17 @@ static int __devinit natsemi_probe1 (str
 
 
 	return 0;
+
+ err_register_netdev:
+	iounmap ((void *) dev->base_addr);
+
+ err_ioremap:
+	pci_release_regions(pdev);
+	pci_set_drvdata(pdev, NULL);
+
+ err_pci_request_regions:
+	free_netdev(dev);
+	return i;
 }
 
 

_

             reply	other threads:[~2003-10-04  4:29 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-10-04  4:29 Randy.Dunlap [this message]
2003-10-14 18:38 ` [PATCH] janitor: insert missing iounmap(), add error handling Jeff Garzik

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20031003212904.34d4ca01.rddunlap@osdl.org \
    --to=rddunlap@osdl.org \
    --cc=jgarzik@pobox.com \
    --cc=netdev@oss.sgi.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).