[PATCH] kmalloc check for drivers/media/video/i2c-parport.c (245ac16)

From: Rasmus Andersen (rasmus@jaquet.dk)
Date: Sun Jun 24 2001 - 16:30:06 EST


Hi.

The following patch tries to avoid a potential null pointer
dereference. It applies against 245-ac16 and 246p6. The
dereference was originally reported by the Stanford team.

--- linux-245-ac16-clean/drivers/media/video/i2c-parport.c Thu Jul 13 01:24:33 2000
+++ linux-245-ac16/drivers/media/video/i2c-parport.c Sun Jun 24 23:22:19 2001
@@ -74,6 +74,10 @@
 {
   struct parport_i2c_bus *b = kmalloc(sizeof(struct parport_i2c_bus),
                                       GFP_KERNEL);
+ if (!b) {
+ printk(KERN_ERR __FUNCTION__ ": Memory allocation failed. Not attaching.\n");
+ return;
+ }
   b->i2c = parport_i2c_bus_template;
   b->i2c.data = parport_get_port (port);
   strncpy(b->i2c.name, port->name, 32);

-- 
Regards,
        Rasmus(rasmus@jaquet.dk)

"A statesman... is a dead politician. Lord knows, we need more statesmen." -- Bloom County - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Sat Jun 30 2001 - 21:00:10 EST