diff mbox

can: Fix possible NULL pointer dereference in ems_usb.c

Message ID 20100420135538.GA1994@bluebox.local
State Changes Requested, archived
Delegated to: David Miller
Headers show

Commit Message

Hans J. Koch April 20, 2010, 1:55 p.m. UTC
In ems_usb_probe(), a pointer is dereferenced after making sure it is NULL...

This patch replaces dev_err() with printk() to avoid this.

Signed-off-by: "Hans J. Koch" <hjk@linutronix.de>
---
 drivers/net/can/usb/ems_usb.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Comments

Wolfgang Grandegger April 20, 2010, 7:47 p.m. UTC | #1
Hans J. Koch wrote:
> In ems_usb_probe(), a pointer is dereferenced after making sure it is NULL...
> 
> This patch replaces dev_err() with printk() to avoid this.
> 
> Signed-off-by: "Hans J. Koch" <hjk@linutronix.de>
> ---
>  drivers/net/can/usb/ems_usb.c |    2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> Index: linux-2.6.34-rc/drivers/net/can/usb/ems_usb.c
> ===================================================================
> --- linux-2.6.34-rc.orig/drivers/net/can/usb/ems_usb.c	2010-04-20 15:32:25.000000000 +0200
> +++ linux-2.6.34-rc/drivers/net/can/usb/ems_usb.c	2010-04-20 15:33:20.000000000 +0200
> @@ -1006,7 +1006,7 @@
>  
>  	netdev = alloc_candev(sizeof(struct ems_usb), MAX_TX_URBS);
>  	if (!netdev) {
> -		dev_err(netdev->dev.parent, "Couldn't alloc candev\n");
> +		printk(KERN_ERR "ems_usb: Couldn't alloc candev\n");
>  		return -ENOMEM;
>  	}

I think "dev_err(&intf->dev, ...)" should be used before
SET_NETDEV_DEV(netdev, &intf->dev) is called. I see two "dev_err()"
calls which need to be fixed.

Wolfgang.

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
David Miller April 21, 2010, 1:05 a.m. UTC | #2
From: Wolfgang Grandegger <wg@grandegger.com>
Date: Tue, 20 Apr 2010 21:47:37 +0200

> Hans J. Koch wrote:
>> In ems_usb_probe(), a pointer is dereferenced after making sure it is NULL...
>> 
>> This patch replaces dev_err() with printk() to avoid this.
>> 
>> Signed-off-by: "Hans J. Koch" <hjk@linutronix.de>
>> ---
>>  drivers/net/can/usb/ems_usb.c |    2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>> 
>> Index: linux-2.6.34-rc/drivers/net/can/usb/ems_usb.c
>> ===================================================================
>> --- linux-2.6.34-rc.orig/drivers/net/can/usb/ems_usb.c	2010-04-20 15:32:25.000000000 +0200
>> +++ linux-2.6.34-rc/drivers/net/can/usb/ems_usb.c	2010-04-20 15:33:20.000000000 +0200
>> @@ -1006,7 +1006,7 @@
>>  
>>  	netdev = alloc_candev(sizeof(struct ems_usb), MAX_TX_URBS);
>>  	if (!netdev) {
>> -		dev_err(netdev->dev.parent, "Couldn't alloc candev\n");
>> +		printk(KERN_ERR "ems_usb: Couldn't alloc candev\n");
>>  		return -ENOMEM;
>>  	}
> 
> I think "dev_err(&intf->dev, ...)" should be used before
> SET_NETDEV_DEV(netdev, &intf->dev) is called. I see two "dev_err()"
> calls which need to be fixed.

Agreed.
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

Index: linux-2.6.34-rc/drivers/net/can/usb/ems_usb.c
===================================================================
--- linux-2.6.34-rc.orig/drivers/net/can/usb/ems_usb.c	2010-04-20 15:32:25.000000000 +0200
+++ linux-2.6.34-rc/drivers/net/can/usb/ems_usb.c	2010-04-20 15:33:20.000000000 +0200
@@ -1006,7 +1006,7 @@ 
 
 	netdev = alloc_candev(sizeof(struct ems_usb), MAX_TX_URBS);
 	if (!netdev) {
-		dev_err(netdev->dev.parent, "Couldn't alloc candev\n");
+		printk(KERN_ERR "ems_usb: Couldn't alloc candev\n");
 		return -ENOMEM;
 	}