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

Rasmus Andersen (rasmus@jaquet.dk)
Sun, 24 Jun 2001 23:30:06 +0200


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/