public inbox for linux-media@vger.kernel.org
 help / color / mirror / Atom feed
From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
To: Sakari Ailus <sakari.ailus@linux.intel.com>
Cc: linux-media@vger.kernel.org, hverkuil@xs4all.nl,
	mchehab@osg.samsung.com, shuahkh@osg.samsung.com
Subject: Re: [RFC v4 01/21] Revert "[media] media: fix media devnode ioctl/syscall and unregister race"
Date: Tue, 22 Nov 2016 12:01:39 +0200	[thread overview]
Message-ID: <5398240.2zSPZQBYuK@avalon> (raw)
In-Reply-To: <1478613330-24691-1-git-send-email-sakari.ailus@linux.intel.com>

Hi Sakari,

Thank you for the patch.

On Tuesday 08 Nov 2016 15:55:10 Sakari Ailus wrote:
> This reverts commit 6f0dd24a084a ("[media] media: fix media devnode
> ioctl/syscall and unregister race"). The commit was part of an original
> patchset to avoid crashes when an unregistering device is in use.
> 
> Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>

For 01/21 to 03/21,

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

> ---
>  drivers/media/media-device.c  | 15 +++++++--------
>  drivers/media/media-devnode.c |  8 +-------
>  include/media/media-devnode.h | 16 ++--------------
>  3 files changed, 10 insertions(+), 29 deletions(-)
> 
> diff --git a/drivers/media/media-device.c b/drivers/media/media-device.c
> index 2783531..f2525eb 100644
> --- a/drivers/media/media-device.c
> +++ b/drivers/media/media-device.c
> @@ -730,7 +730,6 @@ int __must_check __media_device_register(struct
> media_device *mdev, if (ret < 0) {
>  		/* devnode free is handled in media_devnode_*() */
>  		mdev->devnode = NULL;
> -		media_devnode_unregister_prepare(devnode);
>  		media_devnode_unregister(devnode);
>  		return ret;
>  	}
> @@ -787,9 +786,6 @@ void media_device_unregister(struct media_device *mdev)
>  		return;
>  	}
> 
> -	/* Clear the devnode register bit to avoid races with media dev open 
*/
> -	media_devnode_unregister_prepare(mdev->devnode);
> -
>  	/* Remove all entities from the media device */
>  	list_for_each_entry_safe(entity, next, &mdev->entities, 
graph_obj.list)
>  		__media_device_unregister_entity(entity);
> @@ -810,10 +806,13 @@ void media_device_unregister(struct media_device
> *mdev)
> 
>  	dev_dbg(mdev->dev, "Media device unregistered\n");
> 
> -	device_remove_file(&mdev->devnode->dev, &dev_attr_model);
> -	media_devnode_unregister(mdev->devnode);
> -	/* devnode free is handled in media_devnode_*() */
> -	mdev->devnode = NULL;
> +	/* Check if mdev devnode was registered */
> +	if (media_devnode_is_registered(mdev->devnode)) {
> +		device_remove_file(&mdev->devnode->dev, &dev_attr_model);
> +		media_devnode_unregister(mdev->devnode);
> +		/* devnode free is handled in media_devnode_*() */
> +		mdev->devnode = NULL;
> +	}
>  }
>  EXPORT_SYMBOL_GPL(media_device_unregister);
> 
> diff --git a/drivers/media/media-devnode.c b/drivers/media/media-devnode.c
> index f2772ba..5b605ff 100644
> --- a/drivers/media/media-devnode.c
> +++ b/drivers/media/media-devnode.c
> @@ -287,7 +287,7 @@ int __must_check media_devnode_register(struct
> media_device *mdev, return ret;
>  }
> 
> -void media_devnode_unregister_prepare(struct media_devnode *devnode)
> +void media_devnode_unregister(struct media_devnode *devnode)
>  {
>  	/* Check if devnode was ever registered at all */
>  	if (!media_devnode_is_registered(devnode))
> @@ -295,12 +295,6 @@ void media_devnode_unregister_prepare(struct
> media_devnode *devnode)
> 
>  	mutex_lock(&media_devnode_lock);
>  	clear_bit(MEDIA_FLAG_REGISTERED, &devnode->flags);
> -	mutex_unlock(&media_devnode_lock);
> -}
> -
> -void media_devnode_unregister(struct media_devnode *devnode)
> -{
> -	mutex_lock(&media_devnode_lock);
>  	/* Delete the cdev on this minor as well */
>  	cdev_del(&devnode->cdev);
>  	mutex_unlock(&media_devnode_lock);
> diff --git a/include/media/media-devnode.h b/include/media/media-devnode.h
> index cd23e91..d55ec2b 100644
> --- a/include/media/media-devnode.h
> +++ b/include/media/media-devnode.h
> @@ -128,26 +128,14 @@ int __must_check media_devnode_register(struct
> media_device *mdev, struct module *owner);
> 
>  /**
> - * media_devnode_unregister_prepare - clear the media device node register
> bit - * @devnode: the device node to prepare for unregister
> - *
> - * This clears the passed device register bit. Future open calls will be
> met - * with errors. Should be called before media_devnode_unregister() to
> avoid - * races with unregister and device file open calls.
> - *
> - * This function can safely be called if the device node has never been
> - * registered or has already been unregistered.
> - */
> -void media_devnode_unregister_prepare(struct media_devnode *devnode);
> -
> -/**
>   * media_devnode_unregister - unregister a media device node
>   * @devnode: the device node to unregister
>   *
>   * This unregisters the passed device. Future open calls will be met with
>   * errors.
>   *
> - * Should be called after media_devnode_unregister_prepare()
> + * This function can safely be called if the device node has never been
> + * registered or has already been unregistered.
>   */
>  void media_devnode_unregister(struct media_devnode *devnode);

-- 
Regards,

Laurent Pinchart


      parent reply	other threads:[~2016-11-22 10:01 UTC|newest]

Thread overview: 43+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-11-08 13:54 [RFC v4 00/21] Make use of kref in media device, grab references as needed Sakari Ailus
2016-11-08 13:55 ` [RFC v4 01/21] Revert "[media] media: fix media devnode ioctl/syscall and unregister race" Sakari Ailus
2016-11-08 13:55   ` [RFC v4 02/21] Revert "[media] media: fix use-after-free in cdev_put() when app exits after driver unbind" Sakari Ailus
2016-11-08 13:55   ` [RFC v4 03/21] Revert "[media] media-device: dynamically allocate struct media_devnode" Sakari Ailus
2016-11-08 13:55   ` [RFC v4 04/21] media: Remove useless curly braces and parentheses Sakari Ailus
2016-11-22  9:59     ` Laurent Pinchart
2016-11-08 13:55   ` [RFC v4 05/21] media: devnode: Rename mdev argument as devnode Sakari Ailus
2016-11-22 10:00     ` Laurent Pinchart
2016-11-08 13:55   ` [RFC v4 06/21] media device: Drop nop release callback Sakari Ailus
2016-11-22 10:01     ` Laurent Pinchart
2016-11-08 13:55   ` [RFC v4 07/21] media-device: Make devnode.dev->kobj parent of devnode.cdev Sakari Ailus
2016-11-08 13:55   ` [RFC v4 08/21] media: Enable allocating the media device dynamically Sakari Ailus
2016-11-08 19:20     ` Shuah Khan
2016-11-10 23:53       ` Laurent Pinchart
2016-11-11  0:00         ` Shuah Khan
2016-11-11  0:11           ` Laurent Pinchart
2016-11-11  0:16             ` Shuah Khan
2016-11-11  0:19               ` Laurent Pinchart
2016-11-11  0:35                 ` Shuah Khan
2016-11-14 13:40       ` Sakari Ailus
2016-11-15  0:13         ` Shuah Khan
2016-11-08 13:55   ` [RFC v4 09/21] media: Split initialising and adding media devnode Sakari Ailus
2016-11-08 13:55   ` [RFC v4 10/21] media: Shuffle functions around Sakari Ailus
2016-11-08 13:55   ` [RFC v4 11/21] media device: Refcount the media device Sakari Ailus
2016-11-08 13:55   ` [RFC v4 12/21] media device: Initialise media devnode in media_device_init() Sakari Ailus
2016-11-08 13:55   ` [RFC v4 13/21] media device: Deprecate media_device_{init,cleanup}() for drivers Sakari Ailus
2016-11-08 13:55   ` [RFC v4 14/21] media device: Get the media device driver's device Sakari Ailus
2016-11-22  9:46     ` Hans Verkuil
2016-11-22  9:58       ` Laurent Pinchart
2016-11-22 10:58         ` Hans Verkuil
2016-11-22 22:16           ` Laurent Pinchart
2016-11-08 13:55   ` [RFC v4 15/21] media: Provide a way to the driver to set a private pointer Sakari Ailus
2016-11-08 13:55   ` [RFC v4 16/21] media: Add release callback for media device Sakari Ailus
2016-11-08 13:55   ` [RFC v4 17/21] v4l: Acquire a reference to the media device for every video device Sakari Ailus
2016-11-08 13:55   ` [RFC v4 18/21] media-device: Postpone graph object removal until free Sakari Ailus
2016-11-08 13:55   ` [RFC v4 19/21] omap3isp: Allocate the media device dynamically Sakari Ailus
2016-11-22 10:05     ` Hans Verkuil
2016-12-02 14:52       ` Sakari Ailus
2016-11-08 13:55   ` [RFC v4 20/21] omap3isp: Release the isp device struct by media device callback Sakari Ailus
2016-11-08 13:55   ` [RFC v4 21/21] omap3isp: Don't rely on devm for memory resource management Sakari Ailus
2016-11-08 17:00   ` [RFC v4 01/21] Revert "[media] media: fix media devnode ioctl/syscall and unregister race" Mauro Carvalho Chehab
2016-11-10 23:49     ` Laurent Pinchart
2016-11-22 10:01   ` 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=5398240.2zSPZQBYuK@avalon \
    --to=laurent.pinchart@ideasonboard.com \
    --cc=hverkuil@xs4all.nl \
    --cc=linux-media@vger.kernel.org \
    --cc=mchehab@osg.samsung.com \
    --cc=sakari.ailus@linux.intel.com \
    --cc=shuahkh@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