public inbox for linux-media@vger.kernel.org
 help / color / mirror / Atom feed
From: Shuah Khan <shuahkh@osg.samsung.com>
To: Mauro Carvalho Chehab <mchehab@osg.samsung.com>,
	Linux Media Mailing List <linux-media@vger.kernel.org>
Cc: "Mauro Carvalho Chehab" <mchehab@infradead.org>,
	"Hans Verkuil" <hans.verkuil@cisco.com>,
	"Rafael Lourenço de Lima Chehab" <chehabrafael@gmail.com>,
	"Shuah Khan" <shuahkh@osg.samsung.com>
Subject: Re: [PATCH 3/5] [media] au0828: Unregister notifiers
Date: Tue, 22 Mar 2016 13:55:42 -0600	[thread overview]
Message-ID: <56F1A33E.10403@osg.samsung.com> (raw)
In-Reply-To: <cdba12a00adbecabb66a662982991178383917b2.1458129823.git.mchehab@osg.samsung.com>

On 03/16/2016 06:04 AM, Mauro Carvalho Chehab wrote:
> If au0828 gets removed, we need to remove the notifiers.
> 
> Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>

Tested bind_unbind au0828 loop 1000 times, followed by bind_unbind
snd_usb_audio loop 1000 times. Didn't see any lock warnings on a
KASAN enabled kernel (lock testing enabled). No use-after-free errors
during these runs.

Ran device removal test and rmmod and modprobe tests on both drivers.

Generated graph after the runs and the graph looks good.

Reviewed-by: Shuah Khan <shuahkh@osg.samsung.com>
Tested-by: Shuah Khan <shuahkh@osg.samsung.com>

thanks,
-- Shuah

> ---
>  drivers/media/usb/au0828/au0828-core.c | 34 ++++++++++++++++++++++++----------
>  1 file changed, 24 insertions(+), 10 deletions(-)
> 
> diff --git a/drivers/media/usb/au0828/au0828-core.c b/drivers/media/usb/au0828/au0828-core.c
> index 2fcd17d9b1a6..06da73f1ff22 100644
> --- a/drivers/media/usb/au0828/au0828-core.c
> +++ b/drivers/media/usb/au0828/au0828-core.c
> @@ -131,21 +131,35 @@ static int recv_control_msg(struct au0828_dev *dev, u16 request, u32 value,
>  	return status;
>  }
>  
> +#ifdef CONFIG_MEDIA_CONTROLLER
> +static void au0828_media_graph_notify(struct media_entity *new,
> +				      void *notify_data);
> +#endif
> +
>  static void au0828_unregister_media_device(struct au0828_dev *dev)
>  {
> -
>  #ifdef CONFIG_MEDIA_CONTROLLER
> -	if (dev->media_dev &&
> -		media_devnode_is_registered(&dev->media_dev->devnode)) {
> -		/* clear enable_source, disable_source */
> -		dev->media_dev->source_priv = NULL;
> -		dev->media_dev->enable_source = NULL;
> -		dev->media_dev->disable_source = NULL;
> +	struct media_device *mdev = dev->media_dev;
> +	struct media_entity_notify *notify, *nextp;
>  
> -		media_device_unregister(dev->media_dev);
> -		media_device_cleanup(dev->media_dev);
> -		dev->media_dev = NULL;
> +	if (!mdev || !media_devnode_is_registered(&mdev->devnode))
> +		return;
> +
> +	/* Remove au0828 entity_notify callbacks */
> +	list_for_each_entry_safe(notify, nextp, &mdev->entity_notify, list) {
> +		if (notify->notify != au0828_media_graph_notify)
> +			continue;
> +		media_device_unregister_entity_notify(mdev, notify);
>  	}
> +
> +	/* clear enable_source, disable_source */
> +	dev->media_dev->source_priv = NULL;
> +	dev->media_dev->enable_source = NULL;
> +	dev->media_dev->disable_source = NULL;
> +
> +	media_device_unregister(dev->media_dev);
> +	media_device_cleanup(dev->media_dev);
> +	dev->media_dev = NULL;
>  #endif
>  }
>  
> 


-- 
Shuah Khan
Sr. Linux Kernel Developer
Open Source Innovation Group
Samsung Research America (Silicon Valley)
shuahkh@osg.samsung.com | (970) 217-8978

  parent reply	other threads:[~2016-03-22 19:55 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-03-16 12:04 [PATCH 1/5] [media] media-device: get rid of the spinlock Mauro Carvalho Chehab
2016-03-16 12:04 ` [PATCH 2/5] [media] media-device: Fix a comment Mauro Carvalho Chehab
2016-03-16 12:58   ` Javier Martinez Canillas
2016-03-16 12:04 ` [PATCH 3/5] [media] au0828: Unregister notifiers Mauro Carvalho Chehab
2016-03-16 13:11   ` Javier Martinez Canillas
2016-03-22 19:55   ` Shuah Khan [this message]
2016-03-16 12:04 ` [PATCH 4/5] [media] media-device: use kref for media_device instance Mauro Carvalho Chehab
2016-03-16 13:23   ` Javier Martinez Canillas
2016-03-16 14:05   ` Shuah Khan
2016-03-16 14:25     ` Mauro Carvalho Chehab
2016-03-16 14:32       ` Shuah Khan
2016-03-17 11:50   ` Sakari Ailus
2016-03-18 11:17     ` Mauro Carvalho Chehab
2016-03-18 13:10   ` Sakari Ailus
2016-03-22 19:56   ` Shuah Khan
2016-03-22 20:07     ` Shuah Khan
2016-03-16 12:04 ` [PATCH 5/5] [media] media-device: make media_device_cleanup() static Mauro Carvalho Chehab
2016-03-16 14:03   ` Javier Martinez Canillas
2016-03-16 14:36     ` Mauro Carvalho Chehab
2016-03-16 14:38       ` Javier Martinez Canillas
2016-03-22 19:57   ` Shuah Khan
2016-03-16 12:53 ` [PATCH 1/5] [media] media-device: get rid of the spinlock Javier Martinez Canillas
2016-03-16 13:10   ` Mauro Carvalho Chehab
2016-03-16 14:10 ` Sakari Ailus
2016-03-22 19:52 ` Shuah Khan
2016-03-24 22:11 ` Laurent Pinchart

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=56F1A33E.10403@osg.samsung.com \
    --to=shuahkh@osg.samsung.com \
    --cc=chehabrafael@gmail.com \
    --cc=hans.verkuil@cisco.com \
    --cc=linux-media@vger.kernel.org \
    --cc=mchehab@infradead.org \
    --cc=mchehab@osg.samsung.com \
    /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