public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Alban Bedel <alban.bedel@avionic-design.de>
To: Javier Martinez Canillas <javier@osg.samsung.com>
Cc: Alban Bedel <alban.bedel@avionic-design.de>,
	linux-media@vger.kernel.org,
	Mauro Carvalho Chehab <mchehab@osg.samsung.com>,
	Sakari Ailus <sakari.ailus@iki.fi>, Bryan Wu <cooloney@gmail.com>,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] [media] v4l2-async: Always unregister the subdev on failure
Date: Wed, 11 May 2016 18:32:52 +0200	[thread overview]
Message-ID: <20160511183252.6270d740@avionic-0020> (raw)
In-Reply-To: <429cc087-85e3-7bfa-b0b6-ab9434e5d47c@osg.samsung.com>

[-- Attachment #1: Type: text/plain, Size: 1983 bytes --]

On Wed, 11 May 2016 12:22:44 -0400
Javier Martinez Canillas <javier@osg.samsung.com> wrote:

> Hello Alban,
> 
> On 05/11/2016 11:40 AM, Alban Bedel wrote:
> > In v4l2_async_test_notify() if the registered_async callback or the
> > complete notifier returns an error the subdev is not unregistered.
> > This leave paths where v4l2_async_register_subdev() can fail but
> > leave the subdev still registered.
> > 
> > Add the required calls to v4l2_device_unregister_subdev() to plug
> > these holes.
> > 
> > Signed-off-by: Alban Bedel <alban.bedel@avionic-design.de>
> > ---
> >  drivers/media/v4l2-core/v4l2-async.c | 10 ++++++++--
> >  1 file changed, 8 insertions(+), 2 deletions(-)
> > 
> > diff --git a/drivers/media/v4l2-core/v4l2-async.c b/drivers/media/v4l2-core/v4l2-async.c
> > index ceb28d4..43393f8 100644
> > --- a/drivers/media/v4l2-core/v4l2-async.c
> > +++ b/drivers/media/v4l2-core/v4l2-async.c
> > @@ -121,13 +121,19 @@ static int v4l2_async_test_notify(struct v4l2_async_notifier *notifier,
> >  
> >  	ret = v4l2_subdev_call(sd, core, registered_async);
> >  	if (ret < 0 && ret != -ENOIOCTLCMD) {
> > +		v4l2_device_unregister_subdev(sd);
> >  		if (notifier->unbind)
> >  			notifier->unbind(notifier, sd, asd);
> >  		return ret;
> >  	}
> >  
> > -	if (list_empty(&notifier->waiting) && notifier->complete)
> > -		return notifier->complete(notifier);
> > +	if (list_empty(&notifier->waiting) && notifier->complete) {
> > +		ret = notifier->complete(notifier);
> > +		if (ret < 0) {
> > +			v4l2_device_unregister_subdev(sd);
> 
> Isn't a call to notifier->unbind() missing here as well?
> 
> Also, I think the error path is becoming too duplicated and complex, so
> maybe we can have a single error path and use goto labels as is common
> in Linux? For example something like the following (not tested) can be
> squashed on top of your change:

Yes, that look better. I'll test it and report tomorrow.

Alban

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

  reply	other threads:[~2016-05-11 16:33 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-05-11 15:40 [PATCH] [media] v4l2-async: Always unregister the subdev on failure Alban Bedel
2016-05-11 16:22 ` Javier Martinez Canillas
2016-05-11 16:32   ` Alban Bedel [this message]
2016-07-01 11:55     ` Hans Verkuil
2016-08-24 13:49       ` Alban Bedel

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=20160511183252.6270d740@avionic-0020 \
    --to=alban.bedel@avionic-design.de \
    --cc=cooloney@gmail.com \
    --cc=javier@osg.samsung.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=mchehab@osg.samsung.com \
    --cc=sakari.ailus@iki.fi \
    /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