public inbox for linux-media@vger.kernel.org
 help / color / mirror / Atom feed
From: Sylwester Nawrocki <s.nawrocki@samsung.com>
To: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Cc: linux-media@vger.kernel.org,
	Guennadi Liakhovetski <g.liakhovetski@gmx.de>
Subject: Re: [PATCH v2] v4l: async: Make it safe to unregister unregistered notifier
Date: Thu, 08 Aug 2013 17:52:00 +0200	[thread overview]
Message-ID: <5203BEA0.4040208@samsung.com> (raw)
In-Reply-To: <1375974259-2807-1-git-send-email-laurent.pinchart@ideasonboard.com>

On 08/08/2013 05:04 PM, Laurent Pinchart wrote:
> Calling v4l2_async_notifier_unregister() on a notifier that hasn't been
> registered leads to a crash. To simplify drivers, make it safe to
> unregister a notifier that has not been registered.
> 
> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

Tested-by: Sylwester Nawrocki <s.nawrocki@samsung.com>
Acked-by: Sylwester Nawrocki <s.nawrocki@samsung.com>

> ---
>  drivers/media/v4l2-core/v4l2-async.c | 6 ++++++
>  1 file changed, 6 insertions(+)
> 
> Compared to v1, I've modified the NULL check to match the coding style used in
> the rest of the file (!... instead of ... != NULL).
> 
> diff --git a/drivers/media/v4l2-core/v4l2-async.c b/drivers/media/v4l2-core/v4l2-async.c
> index b350ab9..10bb62c 100644
> --- a/drivers/media/v4l2-core/v4l2-async.c
> +++ b/drivers/media/v4l2-core/v4l2-async.c
> @@ -192,6 +192,9 @@ void v4l2_async_notifier_unregister(struct v4l2_async_notifier *notifier)
>  	struct device *dev[n_subdev];
>  	int i = 0;
>  
> +	if (!notifier->v4l2_dev)
> +		return;
> +
>  	mutex_lock(&list_lock);
>  
>  	list_del(&notifier->list);
> @@ -225,6 +228,9 @@ void v4l2_async_notifier_unregister(struct v4l2_async_notifier *notifier)
>  		}
>  		put_device(d);
>  	}
> +
> +	notifier->v4l2_dev = NULL;
> +
>  	/*
>  	 * Don't care about the waiting list, it is initialised and populated
>  	 * upon notifier registration.
> 

Regards,
Sylwester

           reply	other threads:[~2013-08-08 15:52 UTC|newest]

Thread overview: expand[flat|nested]  mbox.gz  Atom feed
 [parent not found: <1375974259-2807-1-git-send-email-laurent.pinchart@ideasonboard.com>]

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=5203BEA0.4040208@samsung.com \
    --to=s.nawrocki@samsung.com \
    --cc=g.liakhovetski@gmx.de \
    --cc=laurent.pinchart@ideasonboard.com \
    --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