* [PATCH] can: Fix possible NULL pointer dereference in ems_usb.c
@ 2010-04-20 13:55 Hans J. Koch
[not found] ` <20100420135538.GA1994-hikPBsva6T+Nj9Bq2fkWzw@public.gmane.org>
0 siblings, 1 reply; 6+ messages in thread
From: Hans J. Koch @ 2010-04-20 13:55 UTC (permalink / raw)
To: netdev-u79uwXL29TY76Z2rM5mHXA; +Cc: socketcan-core-0fE9KPoRgkgATYTw5x5z8w
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-hfZtesqFncYOwBW4kG4KsQ@public.gmane.org>
---
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;
}
^ permalink raw reply [flat|nested] 6+ messages in thread[parent not found: <20100420135538.GA1994-hikPBsva6T+Nj9Bq2fkWzw@public.gmane.org>]
* Re: [PATCH] can: Fix possible NULL pointer dereference in ems_usb.c [not found] ` <20100420135538.GA1994-hikPBsva6T+Nj9Bq2fkWzw@public.gmane.org> @ 2010-04-20 19:47 ` Wolfgang Grandegger 2010-04-21 1:05 ` David Miller 0 siblings, 1 reply; 6+ messages in thread From: Wolfgang Grandegger @ 2010-04-20 19:47 UTC (permalink / raw) To: Hans J. Koch Cc: socketcan-core-0fE9KPoRgkgATYTw5x5z8w, netdev-u79uwXL29TY76Z2rM5mHXA 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-hfZtesqFncYOwBW4kG4KsQ@public.gmane.org> > --- > 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. ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] can: Fix possible NULL pointer dereference in ems_usb.c 2010-04-20 19:47 ` Wolfgang Grandegger @ 2010-04-21 1:05 ` David Miller [not found] ` <20100420.180501.08643239.davem-fT/PcQaiUtIeIZ0/mPfg9Q@public.gmane.org> 0 siblings, 1 reply; 6+ messages in thread From: David Miller @ 2010-04-21 1:05 UTC (permalink / raw) To: wg; +Cc: hjk, netdev, socketcan-core 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. ^ permalink raw reply [flat|nested] 6+ messages in thread
[parent not found: <20100420.180501.08643239.davem-fT/PcQaiUtIeIZ0/mPfg9Q@public.gmane.org>]
* Re: [PATCH] can: Fix possible NULL pointer dereference in ems_usb.c [not found] ` <20100420.180501.08643239.davem-fT/PcQaiUtIeIZ0/mPfg9Q@public.gmane.org> @ 2010-04-21 10:18 ` Hans J. Koch [not found] ` <20100421101805.GA1995-hikPBsva6T+Nj9Bq2fkWzw@public.gmane.org> 0 siblings, 1 reply; 6+ messages in thread From: Hans J. Koch @ 2010-04-21 10:18 UTC (permalink / raw) To: David Miller Cc: socketcan-core-0fE9KPoRgkgATYTw5x5z8w, netdev-u79uwXL29TY76Z2rM5mHXA, wg-5Yr1BZd7O62+XT7JhA+gdA On Tue, Apr 20, 2010 at 06:05:01PM -0700, David Miller wrote: > From: Wolfgang Grandegger <wg-5Yr1BZd7O62+XT7JhA+gdA@public.gmane.org> > > 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. Then it should probably look like this: From: "Hans J. Koch" <hjk-hfZtesqFncYOwBW4kG4KsQ@public.gmane.org> To: netdev-u79uwXL29TY76Z2rM5mHXA@public.gmane.org Cc: socketcan-core-0fE9KPoRgkgATYTw5x5z8w@public.gmane.org, Sebastian Haas <haas-zsNKPWJ8Pib6hrUXjxyGrA@public.gmane.org> Subject: [PATCH] can: Fix possible NULL pointer dereference in ems_usb.c In ems_usb_probe(), a pointer is dereferenced after making sure it is NULL... This patch replaces netdev->dev.parent with &intf->dev in dev_err() calls to avoid this. Signed-off-by: "Hans J. Koch" <hjk-hfZtesqFncYOwBW4kG4KsQ@public.gmane.org> --- drivers/net/can/usb/ems_usb.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) Index: net-next-2.6/drivers/net/can/usb/ems_usb.c =================================================================== --- net-next-2.6.orig/drivers/net/can/usb/ems_usb.c 2010-04-13 11:27:33.000000000 +0200 +++ net-next-2.6/drivers/net/can/usb/ems_usb.c 2010-04-21 11:59:04.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"); + dev_err(&intf->dev, "ems_usb: Couldn't alloc candev\n"); return -ENOMEM; } @@ -1036,20 +1036,20 @@ dev->intr_urb = usb_alloc_urb(0, GFP_KERNEL); if (!dev->intr_urb) { - dev_err(netdev->dev.parent, "Couldn't alloc intr URB\n"); + dev_err(&intf->dev, "Couldn't alloc intr URB\n"); goto cleanup_candev; } dev->intr_in_buffer = kzalloc(INTR_IN_BUFFER_SIZE, GFP_KERNEL); if (!dev->intr_in_buffer) { - dev_err(netdev->dev.parent, "Couldn't alloc Intr buffer\n"); + dev_err(&intf->dev, "Couldn't alloc Intr buffer\n"); goto cleanup_intr_urb; } dev->tx_msg_buffer = kzalloc(CPC_HEADER_SIZE + sizeof(struct ems_cpc_msg), GFP_KERNEL); if (!dev->tx_msg_buffer) { - dev_err(netdev->dev.parent, "Couldn't alloc Tx buffer\n"); + dev_err(&intf->dev, "Couldn't alloc Tx buffer\n"); goto cleanup_intr_in_buffer; } ^ permalink raw reply [flat|nested] 6+ messages in thread
[parent not found: <20100421101805.GA1995-hikPBsva6T+Nj9Bq2fkWzw@public.gmane.org>]
* Re: [PATCH] can: Fix possible NULL pointer dereference in ems_usb.c [not found] ` <20100421101805.GA1995-hikPBsva6T+Nj9Bq2fkWzw@public.gmane.org> @ 2010-04-21 10:27 ` Wolfgang Grandegger 2010-04-21 23:15 ` David Miller 0 siblings, 1 reply; 6+ messages in thread From: Wolfgang Grandegger @ 2010-04-21 10:27 UTC (permalink / raw) To: Hans J. Koch Cc: socketcan-core-0fE9KPoRgkgATYTw5x5z8w, netdev-u79uwXL29TY76Z2rM5mHXA, David Miller Hans J. Koch wrote: > On Tue, Apr 20, 2010 at 06:05:01PM -0700, David Miller wrote: >> From: Wolfgang Grandegger <wg-5Yr1BZd7O62+XT7JhA+gdA@public.gmane.org> >>> 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. > > Then it should probably look like this: There are even more dev_err's to be fixed... > From: "Hans J. Koch" <hjk-hfZtesqFncYOwBW4kG4KsQ@public.gmane.org> > To: netdev-u79uwXL29TY76Z2rM5mHXA@public.gmane.org > Cc: socketcan-core-0fE9KPoRgkgATYTw5x5z8w@public.gmane.org, > Sebastian Haas <haas-zsNKPWJ8Pib6hrUXjxyGrA@public.gmane.org> > Subject: [PATCH] can: Fix possible NULL pointer dereference in ems_usb.c > > In ems_usb_probe(), a pointer is dereferenced after making sure it is NULL... > > This patch replaces netdev->dev.parent with &intf->dev in dev_err() calls to > avoid this. > > Signed-off-by: "Hans J. Koch" <hjk-hfZtesqFncYOwBW4kG4KsQ@public.gmane.org> > --- > drivers/net/can/usb/ems_usb.c | 8 ++++---- > 1 file changed, 4 insertions(+), 4 deletions(-) > > Index: net-next-2.6/drivers/net/can/usb/ems_usb.c > =================================================================== > --- net-next-2.6.orig/drivers/net/can/usb/ems_usb.c 2010-04-13 11:27:33.000000000 +0200 > +++ net-next-2.6/drivers/net/can/usb/ems_usb.c 2010-04-21 11:59:04.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"); > + dev_err(&intf->dev, "ems_usb: Couldn't alloc candev\n"); > return -ENOMEM; > } > > @@ -1036,20 +1036,20 @@ > > dev->intr_urb = usb_alloc_urb(0, GFP_KERNEL); > if (!dev->intr_urb) { > - dev_err(netdev->dev.parent, "Couldn't alloc intr URB\n"); > + dev_err(&intf->dev, "Couldn't alloc intr URB\n"); > goto cleanup_candev; > } > > dev->intr_in_buffer = kzalloc(INTR_IN_BUFFER_SIZE, GFP_KERNEL); > if (!dev->intr_in_buffer) { > - dev_err(netdev->dev.parent, "Couldn't alloc Intr buffer\n"); > + dev_err(&intf->dev, "Couldn't alloc Intr buffer\n"); > goto cleanup_intr_urb; > } > > dev->tx_msg_buffer = kzalloc(CPC_HEADER_SIZE + > sizeof(struct ems_cpc_msg), GFP_KERNEL); > if (!dev->tx_msg_buffer) { > - dev_err(netdev->dev.parent, "Couldn't alloc Tx buffer\n"); > + dev_err(&intf->dev, "Couldn't alloc Tx buffer\n"); > goto cleanup_intr_in_buffer; > } Acked-by: Wolfgang Grandegger <wg-5Yr1BZd7O62+XT7JhA+gdA@public.gmane.org> ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] can: Fix possible NULL pointer dereference in ems_usb.c 2010-04-21 10:27 ` Wolfgang Grandegger @ 2010-04-21 23:15 ` David Miller 0 siblings, 0 replies; 6+ messages in thread From: David Miller @ 2010-04-21 23:15 UTC (permalink / raw) To: wg; +Cc: hjk, socketcan-core, netdev From: Wolfgang Grandegger <wg@grandegger.com> Date: Wed, 21 Apr 2010 12:27:50 +0200 >> Subject: [PATCH] can: Fix possible NULL pointer dereference in ems_usb.c >> >> In ems_usb_probe(), a pointer is dereferenced after making sure it is NULL... >> >> This patch replaces netdev->dev.parent with &intf->dev in dev_err() calls to >> avoid this. >> >> Signed-off-by: "Hans J. Koch" <hjk@linutronix.de> ... > Acked-by: Wolfgang Grandegger <wg@grandegger.com> Applied, thanks. ^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2010-04-21 23:15 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-04-20 13:55 [PATCH] can: Fix possible NULL pointer dereference in ems_usb.c Hans J. Koch
[not found] ` <20100420135538.GA1994-hikPBsva6T+Nj9Bq2fkWzw@public.gmane.org>
2010-04-20 19:47 ` Wolfgang Grandegger
2010-04-21 1:05 ` David Miller
[not found] ` <20100420.180501.08643239.davem-fT/PcQaiUtIeIZ0/mPfg9Q@public.gmane.org>
2010-04-21 10:18 ` Hans J. Koch
[not found] ` <20100421101805.GA1995-hikPBsva6T+Nj9Bq2fkWzw@public.gmane.org>
2010-04-21 10:27 ` Wolfgang Grandegger
2010-04-21 23:15 ` David Miller
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).