Skip to contentSkip to conversation

drivers/usb/misc/cypress_cy7c63.c: NULL dereference

DISCUSSION Adrian Bunk 3 participants 3 messages Aug 15, 2006 – Aug 16, 2006 USB

lore
Share & tools
lore
#0 lore raw

The Coverity Checker spotted the following obvious NULL dereference:

<-- snip -->

...
static int cypress_probe(struct usb_interface *interface,
const struct usb_device_id *id)
{
...

        if (dev == NULL) {
                dev_err(&dev->udev->dev, "Out of memory!\n");
                goto error;
        }

...
}
...

<-- snip -->

cu
Adrian

Signature · 6 lines
    Gentoo kernels are 42 times more popular than SUSE kernels among
    KLive users  (a service by SUSE contractor Andrea Arcangeli that
    gathers data about kernels from many users worldwide).

       There are three kinds of lies: Lies, Damn Lies, and Statistics.
                                                    Benjamin Disraeli
#1 lore raw
Quoted 13 lines · Adrian Bunk

The Coverity Checker spotted the following obvious NULL dereference:

<-- snip -->

...
static int cypress_probe(struct usb_interface *interface,
const struct usb_device_id *id)
{
...

        if (dev == NULL) {
                dev_err(&dev->udev->dev, "Out of memory!\n");
                goto error;
        }
Quoted 5 lines

...
}
...

<-- snip -->

Thanks for letting me know, the patch below should fix this.

greg k-h

------------

From: Greg Kroah-Hartman <[email protected]>
Subject: USB: fix bug in cypress_cy7c63.c driver

This was pointed out by Adrian Bunk <[email protected]>, as found by the Coverity Checker.

---
 drivers/usb/misc/cypress_cy7c63.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/usb/misc/cypress_cy7c63.c +1 -1
@@ -208,7 +208,7 @@ static int cypress_probe(struct usb_inte
 	/* allocate memory for our device state and initialize it */
 	dev = kzalloc(sizeof(*dev), GFP_KERNEL);
 	if (dev == NULL) {
-		dev_err(&dev->udev->dev, "Out of memory!\n");
+		dev_err(&interface->dev, "Out of memory!\n");
 		goto error;
 	}
 
#2 lore raw

Thanks guys!
Sorry for that blunder...

Oliver

Quoted 51 lines · Greg KH
Quoted 13 lines · Adrian Bunk

The Coverity Checker spotted the following obvious NULL dereference:

<-- snip -->

...
static int cypress_probe(struct usb_interface *interface,
const struct usb_device_id *id)
{
...

        if (dev == NULL) {
                dev_err(&dev->udev->dev, "Out of memory!\n");
                goto error;
        }
Quoted 5 lines

...
}
...

<-- snip -->

Thanks for letting me know, the patch below should fix this.

greg k-h

------------

From: Greg Kroah-Hartman <[email protected]>
Subject: USB: fix bug in cypress_cy7c63.c driver

This was pointed out by Adrian Bunk <[email protected]>, as found by the Coverity Checker.

---
 drivers/usb/misc/cypress_cy7c63.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/usb/misc/cypress_cy7c63.c +1 -1
@@ -208,7 +208,7 @@ static int cypress_probe(struct usb_inte
 	/* allocate memory for our device state and initialize it */
 	dev = kzalloc(sizeof(*dev), GFP_KERNEL);
 	if (dev == NULL) {
-		dev_err(&dev->udev->dev, "Out of memory!\n");
+		dev_err(&interface->dev, "Out of memory!\n");
 		goto error;
 	}