All of lore.kernel.org
 help / color / mirror / Atom feed
* [janitor] depca: release resources on errors
@ 2004-01-25  6:31 Randy.Dunlap
  2004-01-25 16:36 ` Jeff Garzik
  0 siblings, 1 reply; 5+ messages in thread
From: Randy.Dunlap @ 2004-01-25  6:31 UTC (permalink / raw)
  To: netdev; +Cc: jgarzik


Hi,
Please apply to 2.6.current.

Thanks,
--
~Randy

From: Leann Ogasawara <ogasawara@osdl.org>


Hi All,

Inserts missing iounmap's and release_mem_region's.  Appreciate
feedback.

Leann

diffed against 2.6.1  

===== drivers/net/depca.c 1.20 vs edited =====

diff -puN drivers/net/depca.c~depca_iounmap drivers/net/depca.c

diff -puN drivers/net/depca.c~depca_iounmap drivers/net/depca.c


 linux-262-rc1-bk1-rddunlap/drivers/net/depca.c |    4 ++++
 1 files changed, 4 insertions(+)

diff -puN drivers/net/depca.c~depca_iounmap drivers/net/depca.c
--- linux-262-rc1-bk1/drivers/net/depca.c~depca_iounmap	2004-01-23 15:49:48.000000000 -0800
+++ linux-262-rc1-bk1-rddunlap/drivers/net/depca.c	2004-01-23 15:49:48.000000000 -0800
@@ -771,6 +771,8 @@ static int __init depca_hw_init (struct 
 		status = -ENXIO;
 		if (!irqnum) {
 			printk(" and failed to detect IRQ line.\n");
+			iounmap(lp->sh_mem);
+			release_mem_region(mem_start, mem_len);
 			goto out_priv;
 		} else {
 			for (dev->irq = 0, i = 0; (depca_irq[i]) && (!dev->irq); i++)
@@ -781,6 +783,8 @@ static int __init depca_hw_init (struct 
 
 			if (!dev->irq) {
 				printk(" but incorrect IRQ line detected.\n");
+				iounmap(lp->sh_mem);
+				release_mem_region(mem_start, mem_len);
 				return -ENXIO;
 			}
 		}

_

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [janitor] depca: release resources on errors
  2004-01-25  6:31 [janitor] depca: release resources on errors Randy.Dunlap
@ 2004-01-25 16:36 ` Jeff Garzik
  2004-01-26  3:30   ` Randy.Dunlap
  0 siblings, 1 reply; 5+ messages in thread
From: Jeff Garzik @ 2004-01-25 16:36 UTC (permalink / raw)
  To: Randy.Dunlap; +Cc: netdev

Most of these patches you're sending are already in netdev-2.6, AFAICS...

	Jeff

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [janitor] depca: release resources on errors
  2004-01-25 16:36 ` Jeff Garzik
@ 2004-01-26  3:30   ` Randy.Dunlap
  2004-01-26  4:25     ` Jeff Garzik
  0 siblings, 1 reply; 5+ messages in thread
From: Randy.Dunlap @ 2004-01-26  3:30 UTC (permalink / raw)
  To: Jeff Garzik; +Cc: netdev, ogasawara

On Sun, 25 Jan 2004 11:36:38 -0500 Jeff Garzik <jgarzik@pobox.com> wrote:

| Most of these patches you're sending are already in netdev-2.6, AFAICS...


net: remove unnecessary type casting -- not found in netdev

tc35815: handle ioremap() failure -- still missed (*Leann)

depca: release resource on errors -- yes, already in netdev

dgrs: add iounmap()s to failure paths -- still missed (*Leann)

--
~Randy


*Leann:  Please rediff these 2 patches after Jeff's netdev
patches are merged, or rediff them against his patchsets.
  http://www.kernel.org/pub/linux/kernel/people/jgarzik/patchkits/2.6/

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [janitor] depca: release resources on errors
  2004-01-26  3:30   ` Randy.Dunlap
@ 2004-01-26  4:25     ` Jeff Garzik
  2004-01-30  2:14       ` Leann Ogasawara
  0 siblings, 1 reply; 5+ messages in thread
From: Jeff Garzik @ 2004-01-26  4:25 UTC (permalink / raw)
  To: Randy.Dunlap; +Cc: netdev, ogasawara

Randy.Dunlap wrote:
> On Sun, 25 Jan 2004 11:36:38 -0500 Jeff Garzik <jgarzik@pobox.com> wrote:
> 
> | Most of these patches you're sending are already in netdev-2.6, AFAICS...
> 
> 
> net: remove unnecessary type casting -- not found in netdev

I applied this one


> tc35815: handle ioremap() failure -- still missed (*Leann)

         dev->base_addr = (unsigned long)ioremap(base_addr, 
sizeof(struct tc35815_regs));
         if (!dev->base_addr) {
                 ret = -ENOMEM;
                 goto err_out;
         }


> dgrs: add iounmap()s to failure paths -- still missed (*Leann)

this wants fixing as well

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [janitor] depca: release resources on errors
  2004-01-26  4:25     ` Jeff Garzik
@ 2004-01-30  2:14       ` Leann Ogasawara
  0 siblings, 0 replies; 5+ messages in thread
From: Leann Ogasawara @ 2004-01-30  2:14 UTC (permalink / raw)
  To: Jeff Garzik; +Cc: Randy Dunlap, netdev

On Sun, 2004-01-25 at 20:25, Jeff Garzik wrote:
[snip]
> > dgrs: add iounmap()s to failure paths -- still missed (*Leann)
> 
> this wants fixing as well

Updated and rediffed janitor cleanup for drivers/net/dgrs.c against
netdev-2.6.  I don't have the hardware to fully test, but module
compiled/loaded/unloaded fine.  Feedback appreciated.  Thanks,

Leann

===== drivers/net/dgrs.c 1.23 vs edited =====
--- 1.23/drivers/net/dgrs.c	Thu Jan  8 08:44:05 2004
+++ edited/drivers/net/dgrs.c	Thu Jan 29 17:13:05 2004
@@ -327,8 +327,11 @@
 	 */
 	priv0->vplxdma[PLX_DMA0_MODE/4] = 0xFFFFFFFF;
 	x = priv0->vplxdma[PLX_DMA0_MODE/4];
-	if (x != 0x00001FFF)
+	if (x != 0x00001FFF) {
+		iounmap((void *) priv0->vplxdma);
+		priv0->vplxdma = NULL;
 		return (0);
+	}
 
 	return (1);
 }
@@ -989,6 +992,7 @@
 {
 	DGRS_PRIV	*priv0 = (DGRS_PRIV *) dev0->priv;
 	int		is;
+	int		ret;
 	unsigned long	i;
 
 	static int	iv2is[16] = {
@@ -1004,7 +1008,8 @@
 	if (!priv0->vmem)
 	{
 		printk("%s: cannot map in board memory\n", dev0->name);
-		return -ENXIO;
+		ret = -ENXIO;
+		goto err_out;
 	}
 
 	/*
@@ -1020,7 +1025,8 @@
 		if (!is)
 		{
 			printk("%s: Illegal IRQ %d\n", dev0->name, dev0->irq);
-			return -ENXIO;
+			ret = -ENXIO;
+			goto err_iounmap_vmem;
 		}
 		OUTB(dev0->base_addr + ES4H_AS_31_24,
 			(uchar) (dev0->mem_start >> 24) );
@@ -1047,10 +1053,9 @@
 	memcpy(priv0->vmem, dgrs_code, dgrs_ncode);	/* Load code */
 	if (memcmp(priv0->vmem, dgrs_code, dgrs_ncode))
 	{
-		iounmap(priv0->vmem);
-		priv0->vmem = NULL;
 		printk("%s: download compare failed\n", dev0->name);
-		return -ENXIO;
+		ret = -ENXIO;
+		goto err_iounmap_vplxdma;
 	}
 
 	/*
@@ -1101,7 +1106,8 @@
 	if (priv0->bcomm->bc_status < BC_RUN)
 	{
 		printk("%s: board not operating\n", dev0->name);
-		return -ENXIO;
+		ret = -ENXIO;
+		goto err_iounmap_vplxdma;
 	}
 
 	priv0->port = (PORT *) S2H(priv0->bcomm->bc_port);
@@ -1139,6 +1145,19 @@
 	}
 
 	return (0);
+
+ err_iounmap_vplxdma:
+	if (priv0->vplxdma) {
+		iounmap((void *) priv0->vplxdma);
+		priv0->vplxdma = NULL;
+	}
+
+ err_iounmap_vmem:
+	iounmap(priv0->vmem);
+
+ err_out:
+	priv0->vmem = NULL;
+	return ret;
 }
 
 /*
@@ -1175,7 +1194,7 @@
 	{
 		printk("%s: Illegal Ethernet Address\n", dev->name);
 		rc = -ENXIO;
-		goto err_out;
+		goto err_iounmap;
 	}
 
 	/*
@@ -1187,7 +1206,7 @@
 	
 	rc = request_irq(dev->irq, &dgrs_intr, SA_SHIRQ, "RightSwitch", dev);
 	if (rc)
-		goto err_out;
+		goto err_iounmap;
 
 	priv->intrcnt = 0;
 	for (i = jiffies + 2*HZ + HZ/2; time_after(i, jiffies); )
@@ -1218,6 +1237,15 @@
 
 err_free_irq:
 	free_irq(dev->irq, dev);
+
+err_iounmap:
+	if (priv->vplxdma) {
+		iounmap((void *) priv->vplxdma);
+		priv->vplxdma = NULL;
+	}
+	iounmap(priv->vmem);
+	priv->vmem = NULL;
+
 err_out:
        	return rc;
 }
@@ -1331,13 +1359,21 @@
 
  fail:	
 	while (i >= 0) {
-		struct net_device *d = priv->devtbl[i--];
+		struct net_device *d = priv->devtbl[--i];
 		unregister_netdev(d);
 		free_netdev(d);
 	}
 
  err2:
 	free_irq(dev->irq, dev);
+	if (priv->vplxdma) {
+		iounmap((void *) priv->vplxdma);
+		priv->vplxdma = NULL;
+	}
+
+	iounmap(priv->vmem);
+	priv->vmem = NULL;
+
  err1:
 	free_netdev(dev);
  err0:
@@ -1364,15 +1400,10 @@
 	if (priv->vmem)
 		iounmap(priv->vmem);
 	if (priv->vplxdma)
-		iounmap((uchar *) priv->vplxdma);
+		iounmap((void *) priv->vplxdma);
 
 	if (dev->irq)
 		free_irq(dev->irq, dev);
-
-	for (i = 1; i < priv->nports; ++i) {
-		if (priv->devtbl[i])
-			unregister_netdev(priv->devtbl[i]);
-	}
 }
 
 #ifdef CONFIG_PCI
    

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2004-01-30  2:14 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-01-25  6:31 [janitor] depca: release resources on errors Randy.Dunlap
2004-01-25 16:36 ` Jeff Garzik
2004-01-26  3:30   ` Randy.Dunlap
2004-01-26  4:25     ` Jeff Garzik
2004-01-30  2:14       ` Leann Ogasawara

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.