LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* [PATCH] SUN3/3X Lance trivial fix
@ 2007-02-05 19:13 Cyrill V. Gorcunov
  2007-02-05 20:01 ` Sam Creasey
  2007-02-06 11:36 ` Jiri Slaby
  0 siblings, 2 replies; 6+ messages in thread
From: Cyrill V. Gorcunov @ 2007-02-05 19:13 UTC (permalink / raw)
  To: Sam Creasey; +Cc: linux-kernel-list

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

Signed-off-by: Cyrill V. Gorcunov <gorcunov@gmail.com>

---

 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");
+		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;
 
 

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

* Re: [PATCH] SUN3/3X Lance trivial fix
  2007-02-05 19:13 [PATCH] SUN3/3X Lance trivial fix Cyrill V. Gorcunov
@ 2007-02-05 20:01 ` Sam Creasey
  2007-02-06 11:36 ` Jiri Slaby
  1 sibling, 0 replies; 6+ messages in thread
From: Sam Creasey @ 2007-02-05 20:01 UTC (permalink / raw)
  To: Cyrill V. Gorcunov; +Cc: linux-kernel-list, linux-m68k

On Mon, Feb 05, 2007 at 10:13:21PM +0300, Cyrill V. Gorcunov wrote:
> This patch adds checking for allocated DVMA
> memory and granted IRQ line.
> 
> Signed-off-by: Cyrill V. Gorcunov <gorcunov@gmail.com>

Acked-by: Sam Creasey <sammy@sammy.net>

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

-- Sam

> ---
> 
>  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");
> +		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;
>  
>  

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

* Re: [PATCH] SUN3/3X Lance trivial fix
  2007-02-05 19:13 [PATCH] SUN3/3X Lance trivial fix Cyrill V. Gorcunov
  2007-02-05 20:01 ` Sam Creasey
@ 2007-02-06 11:36 ` Jiri Slaby
  2007-02-06 11:45   ` Jiri Slaby
  1 sibling, 1 reply; 6+ messages in thread
From: Jiri Slaby @ 2007-02-06 11:36 UTC (permalink / raw)
  To: Cyrill V. Gorcunov; +Cc: Sam Creasey, linux-kernel-list

Cyrill V. Gorcunov napsal(a):
> This patch adds checking for allocated DVMA
> memory and granted IRQ line.
> 
> Signed-off-by: Cyrill V. Gorcunov <gorcunov@gmail.com>
> 
> ---
> 
>  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");
> +		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.

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

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

* Re: [PATCH] SUN3/3X Lance trivial fix
  2007-02-06 11:36 ` Jiri Slaby
@ 2007-02-06 11:45   ` Jiri Slaby
  2007-02-06 11:47     ` Jiri Slaby
  0 siblings, 1 reply; 6+ messages in thread
From: Jiri Slaby @ 2007-02-06 11:45 UTC (permalink / raw)
  To: Jiri Slaby; +Cc: Cyrill V. Gorcunov, Sam Creasey, linux-kernel-list

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 <gorcunov@gmail.com>
>>
>> ---
>>
>>  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");
>> +        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?

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

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

* Re: [PATCH] SUN3/3X Lance trivial fix
  2007-02-06 11:45   ` Jiri Slaby
@ 2007-02-06 11:47     ` Jiri Slaby
  2007-02-06 12:52       ` Cyrill V. Gorcunov
  0 siblings, 1 reply; 6+ messages in thread
From: Jiri Slaby @ 2007-02-06 11:47 UTC (permalink / raw)
  To: Jiri Slaby; +Cc: Cyrill V. Gorcunov, Sam Creasey, linux-kernel-list

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 <gorcunov@gmail.com>
>>>
>>> ---
>>>
>>>  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

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

* Re: [PATCH] SUN3/3X Lance trivial fix
  2007-02-06 11:47     ` Jiri Slaby
@ 2007-02-06 12:52       ` Cyrill V. Gorcunov
  0 siblings, 0 replies; 6+ messages in thread
From: Cyrill V. Gorcunov @ 2007-02-06 12:52 UTC (permalink / raw)
  To: Jiri Slaby; +Cc: linux-kernel-list

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 <gorcunov@gmail.com>
| >>>
| >>>---
| >>>
| >>> 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


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

end of thread, other threads:[~2007-02-06 12:55 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-02-05 19:13 [PATCH] SUN3/3X Lance trivial fix Cyrill V. Gorcunov
2007-02-05 20:01 ` Sam Creasey
2007-02-06 11:36 ` Jiri Slaby
2007-02-06 11:45   ` Jiri Slaby
2007-02-06 11:47     ` Jiri Slaby
2007-02-06 12:52       ` Cyrill V. Gorcunov

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).