Skip to contentSkip to conversation

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

PATCH New Rasmus Andersen 1 participant 1 message Jun 24, 2001 Media (V4L/DVB)

lore
Share & tools
lore
#0 lore raw

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

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.

drivers/media/video/i2c-parport.c +4 -0
@@ -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);
Signature · 5 lines
Regards,
        Rasmus([email protected])

"A statesman... is a dead politician. Lord knows, we need more statesmen." 
   -- Bloom County