Commit 291aca4e authored by Dafna Hirschfeld's avatar Dafna Hirschfeld Committed by Mauro Carvalho Chehab

media: vimc: sen: register subdevice only after initialization

vimc_sen_add function first registers the subdevice and then
calls tpg_alloc. If tpg_alloc fails it unregisters the subdevice
and then frees vsen, this cause double free since the release
callback that follows subdevice unregistration also frees vsen.
Signed-off-by: default avatarDafna Hirschfeld <dafna.hirschfeld@collabora.com>
Acked-by: default avatarHelen Koike <helen.koike@collabora.com>
Signed-off-by: default avatarHans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab+samsung@kernel.org>
parent 4996992c
...@@ -358,6 +358,13 @@ struct vimc_ent_device *vimc_sen_add(struct vimc_device *vimc, ...@@ -358,6 +358,13 @@ struct vimc_ent_device *vimc_sen_add(struct vimc_device *vimc,
goto err_free_vsen; goto err_free_vsen;
} }
/* Initialize the test pattern generator */
tpg_init(&vsen->tpg, vsen->mbus_format.width,
vsen->mbus_format.height);
ret = tpg_alloc(&vsen->tpg, VIMC_FRAME_MAX_WIDTH);
if (ret)
goto err_free_hdl;
/* Initialize ved and sd */ /* Initialize ved and sd */
ret = vimc_ent_sd_register(&vsen->ved, &vsen->sd, v4l2_dev, ret = vimc_ent_sd_register(&vsen->ved, &vsen->sd, v4l2_dev,
vcfg_name, vcfg_name,
...@@ -365,7 +372,7 @@ struct vimc_ent_device *vimc_sen_add(struct vimc_device *vimc, ...@@ -365,7 +372,7 @@ struct vimc_ent_device *vimc_sen_add(struct vimc_device *vimc,
(const unsigned long[1]) {MEDIA_PAD_FL_SOURCE}, (const unsigned long[1]) {MEDIA_PAD_FL_SOURCE},
&vimc_sen_int_ops, &vimc_sen_ops); &vimc_sen_int_ops, &vimc_sen_ops);
if (ret) if (ret)
goto err_free_hdl; goto err_free_tpg;
vsen->ved.process_frame = vimc_sen_process_frame; vsen->ved.process_frame = vimc_sen_process_frame;
vsen->dev = &vimc->pdev.dev; vsen->dev = &vimc->pdev.dev;
...@@ -373,17 +380,10 @@ struct vimc_ent_device *vimc_sen_add(struct vimc_device *vimc, ...@@ -373,17 +380,10 @@ struct vimc_ent_device *vimc_sen_add(struct vimc_device *vimc,
/* Initialize the frame format */ /* Initialize the frame format */
vsen->mbus_format = fmt_default; vsen->mbus_format = fmt_default;
/* Initialize the test pattern generator */
tpg_init(&vsen->tpg, vsen->mbus_format.width,
vsen->mbus_format.height);
ret = tpg_alloc(&vsen->tpg, VIMC_FRAME_MAX_WIDTH);
if (ret)
goto err_unregister_ent_sd;
return &vsen->ved; return &vsen->ved;
err_unregister_ent_sd: err_free_tpg:
vimc_ent_sd_unregister(&vsen->ved, &vsen->sd); tpg_free(&vsen->tpg);
err_free_hdl: err_free_hdl:
v4l2_ctrl_handler_free(&vsen->hdl); v4l2_ctrl_handler_free(&vsen->hdl);
err_free_vsen: err_free_vsen:
......
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