linux-media.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Helen Koike <helen.koike@collabora.com>
To: Dafna Hirschfeld <dafna.hirschfeld@collabora.com>,
	linux-media@vger.kernel.org
Cc: ezequiel@collabora.com, andre.almeida@collabora.com,
	skhan@linuxfoundation.org, hverkuil@xs4all.nl,
	kernel@collabora.com, dafna3@gmail.com
Subject: Re: [PATCH v2 3/5] media: vimc: sensor: register subdevice only after initialization
Date: Thu, 3 Oct 2019 12:14:59 -0300	[thread overview]
Message-ID: <a1eff5ed-e386-f72c-7275-7aa1d15ce148@collabora.com> (raw)
In-Reply-To: <20191003104409.15756-4-dafna.hirschfeld@collabora.com>

Hi Dafna,

Could you just rename the title tags to "media: vimc: sen: " to follow the
model of the other commits?

Thanks
Helen

On 10/3/19 7:44 AM, Dafna Hirschfeld wrote:
> 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: Dafna Hirschfeld <dafna.hirschfeld@collabora.com>
> Acked-by: Helen Koike <helen.koike@collabora.com>
> ---
>  drivers/media/platform/vimc/vimc-sensor.c | 20 ++++++++++----------
>  1 file changed, 10 insertions(+), 10 deletions(-)
> 
> diff --git a/drivers/media/platform/vimc/vimc-sensor.c b/drivers/media/platform/vimc/vimc-sensor.c
> index 46dc6a535abe..ee2306c08569 100644
> --- a/drivers/media/platform/vimc/vimc-sensor.c
> +++ b/drivers/media/platform/vimc/vimc-sensor.c
> @@ -358,6 +358,13 @@ struct vimc_ent_device *vimc_sen_add(struct vimc_device *vimc,
>  		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 */
>  	ret = vimc_ent_sd_register(&vsen->ved, &vsen->sd, v4l2_dev,
>  				   vcfg_name,
> @@ -365,7 +372,7 @@ struct vimc_ent_device *vimc_sen_add(struct vimc_device *vimc,
>  				   (const unsigned long[1]) {MEDIA_PAD_FL_SOURCE},
>  				   &vimc_sen_int_ops, &vimc_sen_ops);
>  	if (ret)
> -		goto err_free_hdl;
> +		goto err_free_tpg;
>  
>  	vsen->ved.process_frame = vimc_sen_process_frame;
>  	vsen->dev = &vimc->pdev.dev;
> @@ -373,17 +380,10 @@ struct vimc_ent_device *vimc_sen_add(struct vimc_device *vimc,
>  	/* Initialize the frame format */
>  	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;
>  
> -err_unregister_ent_sd:
> -	vimc_ent_sd_unregister(&vsen->ved,  &vsen->sd);
> +err_free_tpg:
> +	tpg_free(&vsen->tpg);
>  err_free_hdl:
>  	v4l2_ctrl_handler_free(&vsen->hdl);
>  err_free_vsen:
> 

  reply	other threads:[~2019-10-03 15:15 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-03 10:44 [PATCH v2 0/5] media: vimc: bug fixes related to memory management Dafna Hirschfeld
2019-10-03 10:44 ` [PATCH v2 1/5] media: vimc: initialize vim entity pointers to NULL Dafna Hirschfeld
2019-10-03 13:33   ` Helen Koike
2019-10-03 10:44 ` [PATCH v2 2/5] media: vimc: cleanup code that assigns entity in entities array Dafna Hirschfeld
2019-10-03 13:52   ` Helen Koike
2019-10-03 10:44 ` [PATCH v2 3/5] media: vimc: sensor: register subdevice only after initialization Dafna Hirschfeld
2019-10-03 15:14   ` Helen Koike [this message]
2019-10-03 10:44 ` [PATCH v2 4/5] media: vimc: move media_entity_cleanup to release callbacks Dafna Hirschfeld
2019-10-03 10:44 ` [PATCH v2 5/5] media: vimc: remove the helper function vimc_ent_sd_unregister Dafna Hirschfeld
2019-10-03 15:17   ` Helen Koike

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=a1eff5ed-e386-f72c-7275-7aa1d15ce148@collabora.com \
    --to=helen.koike@collabora.com \
    --cc=andre.almeida@collabora.com \
    --cc=dafna.hirschfeld@collabora.com \
    --cc=dafna3@gmail.com \
    --cc=ezequiel@collabora.com \
    --cc=hverkuil@xs4all.nl \
    --cc=kernel@collabora.com \
    --cc=linux-media@vger.kernel.org \
    --cc=skhan@linuxfoundation.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).