Skip to contentSkip to conversation

drivers/char/watchdog/pcwd_usb.c: fix a NULL pointer dereference

PATCH In review Adrian Bunk 2 participants 2 messages Mar 10, 2006 – Mar 12, 2006 Char and misc drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drivers/char/watchdog/pcwd_usb.c: fix a NULL pointer dereference

The Coverity checker noted that this resulted in a NULL pointer reference if we were coming from

        if (usb_pcwd == NULL) {
                printk(KERN_ERR PFX "Out of memory\n");
                goto error;
        }
drivers/char/watchdog/pcwd_usb.c renamed from drivers/char/watchdog/pcwd_usb.c.old +2 -1
@@ -705,7 +705,8 @@ err_out_misc_deregister:
 err_out_unregister_reboot:
 	unregister_reboot_notifier(&usb_pcwd_notifier);
 error:
-	usb_pcwd_delete (usb_pcwd);
+	if (usb_pcwd)
+		usb_pcwd_delete(usb_pcwd);
 	usb_pcwd_device = NULL;
 	return retval;
 }
#1 lore raw

Hi Adrian,

Quoted 10 lines

The Coverity checker noted that this resulted in a NULL pointer reference if we were coming from

        if (usb_pcwd == NULL) {
                printk(KERN_ERR PFX "Out of memory\n");
                goto error;
        }

This is indeed a bug. I added this patch into my linux-2.6-watchdog-mm tree and I have tested it positively with a PCWD-USB card.

Thanks,
Wim.