Skip to contentSkip to conversation

V4L/DVB (9367): kmalloc failure ignored in lgdt3304_attach()

PATCH New Roel Kluin 1 participant 1 message Sep 18, 2009 Media (V4L/DVB)

lore
Share & tools
lore

Roel Kluin

author
#0 lore raw

PATCH 1/1 V4L/DVB (9367): kmalloc failure ignored in lgdt3304_attach()

Prevent NULL dereference if kmalloc() fails.

---
Found with sed: http://kernelnewbies.org/roelkluin

Build tested.

drivers/media/dvb/frontends/lgdt3304.c +2 -0
index eb72a98..e334b5d 100644
@@ -363,6 +363,8 @@ struct dvb_frontend* lgdt3304_attach(const struct lgdt3304_config *config,
 
 	struct lgdt3304_state *state;
 	state = kzalloc(sizeof(struct lgdt3304_state), GFP_KERNEL);
+	if (state == NULL)
+		return NULL;
 	state->addr = config->i2c_address;
 	state->i2c = i2c;
 
drivers/media/dvb/frontends/s921_module.c +2 -0
index 3f5a0e1..3156b64 100644
@@ -169,6 +169,8 @@ struct dvb_frontend* s921_attach(const struct s921_config *config,
 
 	struct s921_state *state;
 	state = kzalloc(sizeof(struct s921_state), GFP_KERNEL);
+	if (state == NULL)
+		return NULL;
 
 	state->addr = config->i2c_address;
 	state->i2c = i2c;