Skip to contentSkip to conversation

V4L/DVB (12098): dereference of state->internal in fe_stv0900_error stv0900_init_internal()

PATCH New Roel Kluin 1 participant 1 message Aug 29, 2009 Media (V4L/DVB)

lore
Share & tools
lore

Roel Kluin

author
#0 lore raw

PATCH 1/1 V4L/DVB (12098): dereference of state->internal in fe_stv0900_error stv0900_init_internal()

state->internal allocation may fail as well as the allocation of stv0900_first_inode or new_node->next_inode in append_internal().

---
Is this the right thing to do if temp_int == NULL?

drivers/media/dvb/frontends/stv0900_core.c +7 -0
index 1da045f..b0aaf90 100644
@@ -1407,7 +1407,14 @@ static enum fe_stv0900_error stv0900_init_internal(struct dvb_frontend *fe,
 		return STV0900_NO_ERROR;
 	} else {
 		state->internal = kmalloc(sizeof(struct stv0900_internal), GFP_KERNEL);
+		if (state->internal == NULL)
+			return STV0900_INVALID_HANDLE;
 		temp_int = append_internal(state->internal);
+		if (temp_int == NULL) {
+			kfree(state->internal);
+			state->internal == NULL;
+			return STV0900_INVALID_HANDLE;
+		}
 		state->internal->dmds_used = 1;
 		state->internal->i2c_adap = state->i2c_adap;
 		state->internal->i2c_addr = state->config->demod_address;