Skip to contentSkip to conversation

SUN3/3X Lance trivial fix

PATCH In review Cyrill V. Gorcunov 3 participants 6 messages Feb 5, 2007 – Feb 6, 2007 Network drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 SUN3/3X Lance trivial fix

This patch adds checking for allocated DVMA
memory and granted IRQ line.

---

 drivers/net/sun3lance.c |    9 ++++++++-
 1 files changed, 8 insertions(+), 1 deletions(-)
drivers/net/sun3lance.c +8 -1
index c62e85d..e4c2c88 100644
@@ -336,13 +336,20 @@ static int __init lance_probe( struct net_device *dev)
 
 	/* XXX - leak? */
 	MEM = dvma_malloc_align(sizeof(struct lance_memory), 0x10000);
+	if (MEM == NULL) {
+		printk(KERN_WARNING "SUN3 Lance couldn't allocate DVMA memory\n");
+		return 0;
+	}
 
 	lp->iobase = (volatile unsigned short *)ioaddr;
 	dev->base_addr = (unsigned long)ioaddr; /* informational only */
 
 	REGA(CSR0) = CSR0_STOP;
 
-	request_irq(LANCE_IRQ, lance_interrupt, IRQF_DISABLED, "SUN3 Lance", dev);
+	if (request_irq(LANCE_IRQ, lance_interrupt, IRQF_DISABLED, "SUN3 Lance", dev) < 0) {
+		printk(KERN_WARNING "SUN3 Lance unable to allocate IRQ\n");
+		return 0;
+	}
 	dev->irq = (unsigned short)LANCE_IRQ;
 
 
Acked-by on v1 1/1
#1 lore raw
Quoted 4 lines · Cyrill V. Gorcunov

This patch adds checking for allocated DVMA
memory and granted IRQ line.

Included in my tree for rolling back into m68k. I'm fine with it going upstream as well.

-- Sam

Quoted 31 lines

---

 drivers/net/sun3lance.c |    9 ++++++++-
 1 files changed, 8 insertions(+), 1 deletions(-)
drivers/net/sun3lance.c +8 -1
index c62e85d..e4c2c88 100644
@@ -336,13 +336,20 @@ static int __init lance_probe( struct net_device *dev)
 
 	/* XXX - leak? */
 	MEM = dvma_malloc_align(sizeof(struct lance_memory), 0x10000);
+	if (MEM == NULL) {
+		printk(KERN_WARNING "SUN3 Lance couldn't allocate DVMA memory\n");
+		return 0;
+	}
 
 	lp->iobase = (volatile unsigned short *)ioaddr;
 	dev->base_addr = (unsigned long)ioaddr; /* informational only */
 
 	REGA(CSR0) = CSR0_STOP;
 
-	request_irq(LANCE_IRQ, lance_interrupt, IRQF_DISABLED, "SUN3 Lance", dev);
+	if (request_irq(LANCE_IRQ, lance_interrupt, IRQF_DISABLED, "SUN3 Lance", dev) < 0) {
+		printk(KERN_WARNING "SUN3 Lance unable to allocate IRQ\n");
+		return 0;
+	}
 	dev->irq = (unsigned short)LANCE_IRQ;
 
 
#2 lore raw
In reply to Cyrill V. Gorcunov

Cyrill V. Gorcunov napsal(a):

Quoted 15 lines

This patch adds checking for allocated DVMA
memory and granted IRQ line.

---

 drivers/net/sun3lance.c |    9 ++++++++-
 1 files changed, 8 insertions(+), 1 deletions(-)
drivers/net/sun3lance.c +0 -0
index c62e85d..e4c2c88 100644

drivers/net/sun3lance.c static int __init lance_probe( struct net_device *dev) · line 345

Quoted 10 lines
drivers/net/sun3lance.c +4 -0
@@ -336,13 +336,20 @@ static int __init lance_probe( struct net_device *dev)
 
 	/* XXX - leak? */
 	MEM = dvma_malloc_align(sizeof(struct lance_memory), 0x10000);
+	if (MEM == NULL) {
+		printk(KERN_WARNING "SUN3 Lance couldn't allocate DVMA memory\n");
+		return 0;
+	}
 
 	lp->iobase = (volatile unsigned short *)ioaddr;
 	dev->base_addr = (unsigned long)ioaddr; /* informational only */

But now, if it fails (and you return 0=OK state) these are not assigned and probably used later.

drivers/net/sun3lance.c static int __init lance_probe( struct net_device *dev) · line 353

Quoted 9 lines
drivers/net/sun3lance.c +4 -1
 	REGA(CSR0) = CSR0_STOP;
 
-	request_irq(LANCE_IRQ, lance_interrupt, IRQF_DISABLED, "SUN3 Lance", dev);
+	if (request_irq(LANCE_IRQ, lance_interrupt, IRQF_DISABLED, "SUN3 Lance", dev) < 0) {
+		printk(KERN_WARNING "SUN3 Lance unable to allocate IRQ\n");
+		return 0;
+	}
 	dev->irq = (unsigned short)LANCE_IRQ;

Not even irq is grabbed.

Is this intended?

regards,

Signature · 4 lines
http://www.fi.muni.cz/~xslaby/            Jiri Slaby
faculty of informatics, masaryk university, brno, cz
e-mail: jirislaby gmail com, gpg pubkey fingerprint:
B674 9967 0407 CE62 ACC8  22A0 32CC 55C3 39D4 7A7E
#3 lore raw

Jiri Slaby napsal(a):

Quoted 26 lines

Cyrill V. Gorcunov napsal(a):

Quoted 25 lines

This patch adds checking for allocated DVMA
memory and granted IRQ line.

---

 drivers/net/sun3lance.c |    9 ++++++++-
 1 files changed, 8 insertions(+), 1 deletions(-)
drivers/net/sun3lance.c +4 -0
index c62e85d..e4c2c88 100644
@@ -336,13 +336,20 @@ static int __init lance_probe( struct net_device 
 *dev)
 
     /* XXX - leak? */
     MEM = dvma_malloc_align(sizeof(struct lance_memory), 0x10000);
+    if (MEM == NULL) {
+        printk(KERN_WARNING "SUN3 Lance couldn't allocate DVMA 
 memory\n");
+        return 0;
+    }
 
Quoted 4 lines

drivers/net/sun3lance.c static int __init lance_probe( struct net_device *dev) · line 345

Quoted 2 lines
drivers/net/sun3lance.c +0 -0
     lp->iobase = (volatile unsigned short *)ioaddr;
     dev->base_addr = (unsigned long)ioaddr; /* informational only */

But now, if it fails (and you return 0=OK state) these are not assigned

Ok, 0 is not OK state, I see it now.

Quoted 10 lines

and probably used later.

Quoted 8 lines
drivers/net/sun3lance.c +2 -1
     REGA(CSR0) = CSR0_STOP;
 
-    request_irq(LANCE_IRQ, lance_interrupt, IRQF_DISABLED, "SUN3 
 Lance", dev);
+    if (request_irq(LANCE_IRQ, lance_interrupt, IRQF_DISABLED, "SUN3 
 Lance", dev) < 0) {
+        printk(KERN_WARNING "SUN3 Lance unable to allocate IRQ\n");

But in that case, you want to dvma_free() here?

Quoted 3 lines
Quoted 3 lines
drivers/net/sun3lance.c +2 -0
+        return 0;
+    }
     dev->irq = (unsigned short)LANCE_IRQ;

regards,

Signature · 4 lines
http://www.fi.muni.cz/~xslaby/            Jiri Slaby
faculty of informatics, masaryk university, brno, cz
e-mail: jirislaby gmail com, gpg pubkey fingerprint:
B674 9967 0407 CE62 ACC8  22A0 32CC 55C3 39D4 7A7E
#4 lore raw

Jiri Slaby napsal(a):

Quoted 19 lines

Jiri Slaby napsal(a):

Quoted 18 lines

Cyrill V. Gorcunov napsal(a):

Quoted 17 lines

This patch adds checking for allocated DVMA
memory and granted IRQ line.

---

 drivers/net/sun3lance.c |    9 ++++++++-
 1 files changed, 8 insertions(+), 1 deletions(-)
drivers/net/sun3lance.c +0 -0
index c62e85d..e4c2c88 100644
@@ -336,13 +336,20 @@ static int __init lance_probe( struct 
 net_device *dev)
 
Quoted 5 lines
Quoted 5 lines

drivers/net/sun3lance.c static int __init lance_probe( struct net_device *dev)

Quoted 5 lines
drivers/net/sun3lance.c +2 -0
     /* XXX - leak? */
     MEM = dvma_malloc_align(sizeof(struct lance_memory), 0x10000);
+    if (MEM == NULL) {
+        printk(KERN_WARNING "SUN3 Lance couldn't allocate DVMA 
 memory\n");

And also iounmap() here...

Quoted 15 lines
Quoted 7 lines

drivers/net/sun3lance.c static int __init lance_probe( struct net_device *dev) · line 345

Quoted 5 lines
drivers/net/sun3lance.c +2 -0
+        return 0;
+    }
 
     lp->iobase = (volatile unsigned short *)ioaddr;
     dev->base_addr = (unsigned long)ioaddr; /* informational only */

But now, if it fails (and you return 0=OK state) these are not assigned

Ok, 0 is not OK state, I see it now.

Quoted 5 lines

and probably used later.

Quoted 3 lines
drivers/net/sun3lance.c +0 -0
     REGA(CSR0) = CSR0_STOP;
 
Quoted 7 lines
Quoted 5 lines

drivers/net/sun3lance.c static int __init lance_probe( struct · line 353

Quoted 5 lines
drivers/net/sun3lance.c +2 -1
-    request_irq(LANCE_IRQ, lance_interrupt, IRQF_DISABLED, "SUN3 
 Lance", dev);
+    if (request_irq(LANCE_IRQ, lance_interrupt, IRQF_DISABLED, "SUN3 
 Lance", dev) < 0) {
+        printk(KERN_WARNING "SUN3 Lance unable to allocate IRQ\n");

But in that case, you want to dvma_free() here?

And here.

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
drivers/net/sun3lance.c +2 -0
+        return 0;
+    }
     dev->irq = (unsigned short)LANCE_IRQ;

regards,

Signature · 4 lines
http://www.fi.muni.cz/~xslaby/            Jiri Slaby
faculty of informatics, masaryk university, brno, cz
e-mail: jirislaby gmail com, gpg pubkey fingerprint:
B674 9967 0407 CE62 ACC8  22A0 32CC 55C3 39D4 7A7E
#5 lore raw

On Tue, Feb 06, 2007 at 12:47:36PM +0100, Jiri Slaby wrote:

| Jiri Slaby napsal(a):
| >Jiri Slaby napsal(a):
| >>Cyrill V. Gorcunov napsal(a):
| >>>This patch adds checking for allocated DVMA
| >>>memory and granted IRQ line.
| >>>
| >>>Signed-off-by: Cyrill V. Gorcunov <[email protected]>
| >>>
| >>>---
| >>>
| >>> drivers/net/sun3lance.c |    9 ++++++++-
| >>> 1 files changed, 8 insertions(+), 1 deletions(-)
| >>>
| >>>diff --git a/drivers/net/sun3lance.c b/drivers/net/sun3lance.c
| >>>index c62e85d..e4c2c88 100644
| >>>--- a/drivers/net/sun3lance.c
| >>>+++ b/drivers/net/sun3lance.c
| >>>@@ -336,13 +336,20 @@ static int __init lance_probe( struct 
| >>>net_device *dev)
| >>> 
| >>>     /* XXX - leak? */
| >>>     MEM = dvma_malloc_align(sizeof(struct lance_memory), 0x10000);
| >>>+    if (MEM == NULL) {
| >>>+        printk(KERN_WARNING "SUN3 Lance couldn't allocate DVMA 
| >>>memory\n");
| 
| And also iounmap() here...
| 
| >>>+        return 0;
| >>>+    }
| >>> 
| >>>     lp->iobase = (volatile unsigned short *)ioaddr;
| >>>     dev->base_addr = (unsigned long)ioaddr; /* informational only */
| >>
| >>But now, if it fails (and you return 0=OK state) these are not assigned 
| >
| >Ok, 0 is not OK state, I see it now.
| >
| >>and probably used later.
| >>
| >>> 
| >>>     REGA(CSR0) = CSR0_STOP;
| >>> 
| >>>-    request_irq(LANCE_IRQ, lance_interrupt, IRQF_DISABLED, "SUN3 
| >>>Lance", dev);
| >>>+    if (request_irq(LANCE_IRQ, lance_interrupt, IRQF_DISABLED, "SUN3 
| >>>Lance", dev) < 0) {
| >>>+        printk(KERN_WARNING "SUN3 Lance unable to allocate IRQ\n");
| >
| >But in that case, you want to dvma_free() here?
| 
| And here.
| 
| >>>+        return 0;
| >>>+    }
| >>>     dev->irq = (unsigned short)LANCE_IRQ;
| 
| regards,
| -- 
| http://www.fi.muni.cz/~xslaby/            Jiri Slaby
| faculty of informatics, masaryk university, brno, cz
| e-mail: jirislaby gmail com, gpg pubkey fingerprint:
| B674 9967 0407 CE62 ACC8  22A0 32CC 55C3 39D4 7A7E

Thanks a lot,

I'll fix it to get iounmap() used. I don't know is there any reason to use dvma_free() - it's just a 'return' function. May be for further? I think you are right - we should use dvma_free() anyway...

Cyrill