Commit 9722e569 authored by Markus Elfring's avatar Markus Elfring Committed by Mauro Carvalho Chehab

media: dvb-frontends: delete jump targets

* Return directly after a call of the function "kzalloc" failed
  at the beginning.

* Move a bit of exception handling code into an if branch.

* Delete jump targets which became unnecessary with this refactoring.
Signed-off-by: default avatarMarkus Elfring <elfring@users.sourceforge.net>
Signed-off-by: default avatarHans Verkuil <hansverk@cisco.com>
parent af28c996
...@@ -556,7 +556,7 @@ struct dvb_frontend *cx24113_attach(struct dvb_frontend *fe, ...@@ -556,7 +556,7 @@ struct dvb_frontend *cx24113_attach(struct dvb_frontend *fe,
int rc; int rc;
if (!state) if (!state)
goto error; return NULL;
/* setup the state */ /* setup the state */
state->config = config; state->config = config;
......
...@@ -226,10 +226,8 @@ static int cx24116_writeregN(struct cx24116_state *state, int reg, ...@@ -226,10 +226,8 @@ static int cx24116_writeregN(struct cx24116_state *state, int reg,
u8 *buf; u8 *buf;
buf = kmalloc(len + 1, GFP_KERNEL); buf = kmalloc(len + 1, GFP_KERNEL);
if (buf == NULL) { if (!buf)
ret = -ENOMEM; return -ENOMEM;
goto error;
}
*(buf) = reg; *(buf) = reg;
memcpy(buf + 1, data, len); memcpy(buf + 1, data, len);
...@@ -250,7 +248,6 @@ static int cx24116_writeregN(struct cx24116_state *state, int reg, ...@@ -250,7 +248,6 @@ static int cx24116_writeregN(struct cx24116_state *state, int reg,
ret = -EREMOTEIO; ret = -EREMOTEIO;
} }
error:
kfree(buf); kfree(buf);
return ret; return ret;
...@@ -1128,7 +1125,7 @@ struct dvb_frontend *cx24116_attach(const struct cx24116_config *config, ...@@ -1128,7 +1125,7 @@ struct dvb_frontend *cx24116_attach(const struct cx24116_config *config,
/* allocate memory for the internal state */ /* allocate memory for the internal state */
state = kzalloc(sizeof(*state), GFP_KERNEL); state = kzalloc(sizeof(*state), GFP_KERNEL);
if (state == NULL) if (state == NULL)
goto error1; return NULL;
state->config = config; state->config = config;
state->i2c = i2c; state->i2c = i2c;
...@@ -1137,8 +1134,9 @@ struct dvb_frontend *cx24116_attach(const struct cx24116_config *config, ...@@ -1137,8 +1134,9 @@ struct dvb_frontend *cx24116_attach(const struct cx24116_config *config,
ret = (cx24116_readreg(state, 0xFF) << 8) | ret = (cx24116_readreg(state, 0xFF) << 8) |
cx24116_readreg(state, 0xFE); cx24116_readreg(state, 0xFE);
if (ret != 0x0501) { if (ret != 0x0501) {
kfree(state);
printk(KERN_INFO "Invalid probe, probably not a CX24116 device\n"); printk(KERN_INFO "Invalid probe, probably not a CX24116 device\n");
goto error2; return NULL;
} }
/* create dvb_frontend */ /* create dvb_frontend */
...@@ -1146,9 +1144,6 @@ struct dvb_frontend *cx24116_attach(const struct cx24116_config *config, ...@@ -1146,9 +1144,6 @@ struct dvb_frontend *cx24116_attach(const struct cx24116_config *config,
sizeof(struct dvb_frontend_ops)); sizeof(struct dvb_frontend_ops));
state->frontend.demodulator_priv = state; state->frontend.demodulator_priv = state;
return &state->frontend; return &state->frontend;
error2: kfree(state);
error1: return NULL;
} }
EXPORT_SYMBOL(cx24116_attach); EXPORT_SYMBOL(cx24116_attach);
......
...@@ -841,7 +841,7 @@ struct dvb_frontend *ds3000_attach(const struct ds3000_config *config, ...@@ -841,7 +841,7 @@ struct dvb_frontend *ds3000_attach(const struct ds3000_config *config,
/* allocate memory for the internal state */ /* allocate memory for the internal state */
state = kzalloc(sizeof(*state), GFP_KERNEL); state = kzalloc(sizeof(*state), GFP_KERNEL);
if (!state) if (!state)
goto error2; return NULL;
state->config = config; state->config = config;
state->i2c = i2c; state->i2c = i2c;
...@@ -850,8 +850,9 @@ struct dvb_frontend *ds3000_attach(const struct ds3000_config *config, ...@@ -850,8 +850,9 @@ struct dvb_frontend *ds3000_attach(const struct ds3000_config *config,
/* check if the demod is present */ /* check if the demod is present */
ret = ds3000_readreg(state, 0x00) & 0xfe; ret = ds3000_readreg(state, 0x00) & 0xfe;
if (ret != 0xe0) { if (ret != 0xe0) {
kfree(state);
printk(KERN_ERR "Invalid probe, probably not a DS3000\n"); printk(KERN_ERR "Invalid probe, probably not a DS3000\n");
goto error3; return NULL;
} }
printk(KERN_INFO "DS3000 chip version: %d.%d attached.\n", printk(KERN_INFO "DS3000 chip version: %d.%d attached.\n",
...@@ -869,11 +870,6 @@ struct dvb_frontend *ds3000_attach(const struct ds3000_config *config, ...@@ -869,11 +870,6 @@ struct dvb_frontend *ds3000_attach(const struct ds3000_config *config,
*/ */
ds3000_set_voltage(&state->frontend, SEC_VOLTAGE_OFF); ds3000_set_voltage(&state->frontend, SEC_VOLTAGE_OFF);
return &state->frontend; return &state->frontend;
error3:
kfree(state);
error2:
return NULL;
} }
EXPORT_SYMBOL(ds3000_attach); EXPORT_SYMBOL(ds3000_attach);
......
...@@ -2073,7 +2073,7 @@ struct dvb_frontend *mb86a20s_attach(const struct mb86a20s_config *config, ...@@ -2073,7 +2073,7 @@ struct dvb_frontend *mb86a20s_attach(const struct mb86a20s_config *config,
/* allocate memory for the internal state */ /* allocate memory for the internal state */
state = kzalloc(sizeof(*state), GFP_KERNEL); state = kzalloc(sizeof(*state), GFP_KERNEL);
if (!state) if (!state)
goto error; return NULL;
/* setup the state */ /* setup the state */
state->config = config; state->config = config;
...@@ -2086,22 +2086,16 @@ struct dvb_frontend *mb86a20s_attach(const struct mb86a20s_config *config, ...@@ -2086,22 +2086,16 @@ struct dvb_frontend *mb86a20s_attach(const struct mb86a20s_config *config,
/* Check if it is a mb86a20s frontend */ /* Check if it is a mb86a20s frontend */
rev = mb86a20s_readreg(state, 0); rev = mb86a20s_readreg(state, 0);
if (rev != 0x13) {
if (rev == 0x13) { kfree(state);
dev_info(&i2c->dev,
"Detected a Fujitsu mb86a20s frontend\n");
} else {
dev_dbg(&i2c->dev, dev_dbg(&i2c->dev,
"Frontend revision %d is unknown - aborting.\n", "Frontend revision %d is unknown - aborting.\n",
rev); rev);
goto error; return NULL;
} }
dev_info(&i2c->dev, "Detected a Fujitsu mb86a20s frontend\n");
return &state->frontend; return &state->frontend;
error:
kfree(state);
return NULL;
} }
EXPORT_SYMBOL(mb86a20s_attach); EXPORT_SYMBOL(mb86a20s_attach);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment