* [bug report] media: stv090x: Implement probe/remove for stv090x
@ 2019-06-18 10:53 Dan Carpenter
2019-06-18 11:29 ` Tobias Klausmann
0 siblings, 1 reply; 2+ messages in thread
From: Dan Carpenter @ 2019-06-18 10:53 UTC (permalink / raw)
To: tobias.johannes.klausmann; +Cc: linux-media
Hello Tobias Klausmann,
The patch eb5005df886b: "media: stv090x: Implement probe/remove for
stv090x" from May 29, 2019, leads to the following static checker
warning:
drivers/media/dvb-frontends/stv090x.c:5032 stv090x_probe()
warn: 'state' was already freed.
drivers/media/dvb-frontends/stv090x.c
4994 static int stv090x_probe(struct i2c_client *client,
4995 const struct i2c_device_id *id)
4996 {
4997 int ret = 0;
4998 struct stv090x_config *config = client->dev.platform_data;
4999
5000 struct stv090x_state *state = NULL;
5001
5002 state = kzalloc(sizeof(*state), GFP_KERNEL);
5003 if (!state) {
5004 ret = -ENOMEM;
5005 goto error;
5006 }
5007
5008 state->verbose = &verbose;
5009 state->config = config;
5010 state->i2c = client->adapter;
5011 state->frontend.ops = stv090x_ops;
5012 state->frontend.demodulator_priv = state;
5013 state->demod = config->demod;
5014 /* Single or Dual mode */
5015 state->demod_mode = config->demod_mode;
5016 state->device = config->device;
5017 /* default */
5018 state->rolloff = STV090x_RO_35;
5019
5020 ret = stv090x_setup_compound(state);
5021 if (ret)
5022 goto error;
stv090x_setup_compound() frees "state" on error.
5023
5024 i2c_set_clientdata(client, state);
5025
5026 /* setup callbacks */
5027 config->get_dvb_frontend = stv090x_get_dvb_frontend;
5028
5029 return 0;
5030
5031 error:
5032 kfree(state);
^^^^^^^^^^^^
Double free.
5033 return ret;
5034 }
regards,
dan carpenter
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [bug report] media: stv090x: Implement probe/remove for stv090x
2019-06-18 10:53 [bug report] media: stv090x: Implement probe/remove for stv090x Dan Carpenter
@ 2019-06-18 11:29 ` Tobias Klausmann
0 siblings, 0 replies; 2+ messages in thread
From: Tobias Klausmann @ 2019-06-18 11:29 UTC (permalink / raw)
To: Dan Carpenter; +Cc: linux-media
Hello Dan,
yes you are right! Yet this was already reported to the Mailinglist and
a patch was provided [1], which will hopefully be pushed to linux-media
git repository.
[1]https://patchwork.linuxtv.org/patch/56811/
Never the less, thanks for the bugreport!
Tobias
Am 18.06.19 um 12:53 schrieb Dan Carpenter:
> Hello Tobias Klausmann,
>
> The patch eb5005df886b: "media: stv090x: Implement probe/remove for
> stv090x" from May 29, 2019, leads to the following static checker
> warning:
>
> drivers/media/dvb-frontends/stv090x.c:5032 stv090x_probe()
> warn: 'state' was already freed.
>
> drivers/media/dvb-frontends/stv090x.c
> 4994 static int stv090x_probe(struct i2c_client *client,
> 4995 const struct i2c_device_id *id)
> 4996 {
> 4997 int ret = 0;
> 4998 struct stv090x_config *config = client->dev.platform_data;
> 4999
> 5000 struct stv090x_state *state = NULL;
> 5001
> 5002 state = kzalloc(sizeof(*state), GFP_KERNEL);
> 5003 if (!state) {
> 5004 ret = -ENOMEM;
> 5005 goto error;
> 5006 }
> 5007
> 5008 state->verbose = &verbose;
> 5009 state->config = config;
> 5010 state->i2c = client->adapter;
> 5011 state->frontend.ops = stv090x_ops;
> 5012 state->frontend.demodulator_priv = state;
> 5013 state->demod = config->demod;
> 5014 /* Single or Dual mode */
> 5015 state->demod_mode = config->demod_mode;
> 5016 state->device = config->device;
> 5017 /* default */
> 5018 state->rolloff = STV090x_RO_35;
> 5019
> 5020 ret = stv090x_setup_compound(state);
> 5021 if (ret)
> 5022 goto error;
>
> stv090x_setup_compound() frees "state" on error.
>
> 5023
> 5024 i2c_set_clientdata(client, state);
> 5025
> 5026 /* setup callbacks */
> 5027 config->get_dvb_frontend = stv090x_get_dvb_frontend;
> 5028
> 5029 return 0;
> 5030
> 5031 error:
> 5032 kfree(state);
> ^^^^^^^^^^^^
> Double free.
>
> 5033 return ret;
> 5034 }
>
> regards,
> dan carpenter
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2019-06-18 11:29 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-06-18 10:53 [bug report] media: stv090x: Implement probe/remove for stv090x Dan Carpenter
2019-06-18 11:29 ` Tobias Klausmann
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.