public inbox for linux-media@vger.kernel.org
 help / color / mirror / Atom feed
From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
To: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Cc: linux-media@vger.kernel.org, Helen Koike <helen.koike@collabora.com>
Subject: Re: [PATCH 7/7] vimc: free vimc_cap_device when the last user disappears
Date: Fri, 22 Feb 2019 13:37:32 +0200	[thread overview]
Message-ID: <20190222113732.GP3522@pendragon.ideasonboard.com> (raw)
In-Reply-To: <20190221142148.3412-8-hverkuil-cisco@xs4all.nl>

Hi Hans,

Thank you for the patch.

On Thu, Feb 21, 2019 at 03:21:48PM +0100, Hans Verkuil wrote:
> Don't free vimc_cap_device immediately, instead do this
> in the video_device release function which is called when the
> last user closes the video device. Only then is it safe to
> free the memory.
> 
> Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
> ---
>  drivers/media/platform/vimc/vimc-capture.c | 13 ++++++++++---
>  1 file changed, 10 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/media/platform/vimc/vimc-capture.c b/drivers/media/platform/vimc/vimc-capture.c
> index ea869631a3f6..3d433361d297 100644
> --- a/drivers/media/platform/vimc/vimc-capture.c
> +++ b/drivers/media/platform/vimc/vimc-capture.c
> @@ -338,6 +338,15 @@ static const struct media_entity_operations vimc_cap_mops = {
>  	.link_validate		= vimc_link_validate,
>  };
>  
> +static void vimc_cap_release(struct video_device *vdev)
> +{
> +	struct vimc_cap_device *vcap = container_of(vdev, struct vimc_cap_device,
> +						    vdev);
> +
> +	vimc_pads_cleanup(vcap->ved.pads);
> +	kfree(vcap);
> +}
> +
>  static void vimc_cap_comp_unbind(struct device *comp, struct device *master,
>  				 void *master_data)
>  {
> @@ -348,8 +357,6 @@ static void vimc_cap_comp_unbind(struct device *comp, struct device *master,
>  	vb2_queue_release(&vcap->queue);
>  	media_entity_cleanup(ved->ent);
>  	video_unregister_device(&vcap->vdev);
> -	vimc_pads_cleanup(vcap->ved.pads);
> -	kfree(vcap);
>  }
>  
>  static void *vimc_cap_process_frame(struct vimc_ent_device *ved,
> @@ -467,7 +474,7 @@ static int vimc_cap_comp_bind(struct device *comp, struct device *master,
>  	vdev = &vcap->vdev;
>  	vdev->device_caps = V4L2_CAP_VIDEO_CAPTURE | V4L2_CAP_STREAMING;
>  	vdev->entity.ops = &vimc_cap_mops;
> -	vdev->release = video_device_release_empty;
> +	vdev->release = vimc_cap_release;

Another use of video_device_release_empty gone, only 80+ to go ;-)

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

>  	vdev->fops = &vimc_cap_fops;
>  	vdev->ioctl_ops = &vimc_cap_ioctl_ops;
>  	vdev->lock = &vcap->lock;

-- 
Regards,

Laurent Pinchart

      reply	other threads:[~2019-02-22 11:37 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-02-21 14:21 [PATCH 0/7] Various core and virtual driver fixes Hans Verkuil
2019-02-21 14:21 ` [PATCH 1/7] cec: fill in cec chardev kobject to ease debugging Hans Verkuil
2019-02-22 11:10   ` Laurent Pinchart
2019-02-21 14:21 ` [PATCH 2/7] media-devnode: fill in media " Hans Verkuil
2019-02-22 11:07   ` Laurent Pinchart
2019-02-21 14:21 ` [PATCH 3/7] vivid: use vzalloc for dev->bitmap_out Hans Verkuil
2019-02-22 11:09   ` Laurent Pinchart
2019-02-21 14:21 ` [PATCH 4/7] media-entity: set ent_enum->bmap to NULL after freeing it Hans Verkuil
2019-02-22 11:17   ` Laurent Pinchart
2019-02-25 11:25     ` Hans Verkuil
2019-02-21 14:21 ` [PATCH 5/7] vim2m: replace devm_kzalloc by kzalloc Hans Verkuil
2019-02-22 11:20   ` Laurent Pinchart
2019-02-25 11:27     ` Hans Verkuil
2019-02-21 14:21 ` [PATCH 6/7] v4l2-device: v4l2_device_release_subdev_node can't reference sd Hans Verkuil
2019-02-22 11:32   ` Laurent Pinchart
2019-03-01 11:46     ` Hans Verkuil
2019-03-05 19:36       ` Laurent Pinchart
2019-02-21 14:21 ` [PATCH 7/7] vimc: free vimc_cap_device when the last user disappears Hans Verkuil
2019-02-22 11:37   ` Laurent Pinchart [this message]

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=20190222113732.GP3522@pendragon.ideasonboard.com \
    --to=laurent.pinchart@ideasonboard.com \
    --cc=helen.koike@collabora.com \
    --cc=hverkuil-cisco@xs4all.nl \
    --cc=linux-media@vger.kernel.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