public inbox for linux-media@vger.kernel.org
 help / color / mirror / Atom feed
From: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
To: Shuah Khan <shuahkh@osg.samsung.com>
Cc: Javier Martinez Canillas <javier@osg.samsung.com>,
	Linux Media Mailing List <linux-media@vger.kernel.org>
Subject: Re: au0828_v4l2_device_register()
Date: Mon, 28 Mar 2016 15:18:10 -0300	[thread overview]
Message-ID: <20160328151810.63364106@recife.lan> (raw)
In-Reply-To: <56F964F9.8080703@osg.samsung.com>

Hi Shuah,

Em Mon, 28 Mar 2016 11:08:09 -0600
Shuah Khan <shuahkh@osg.samsung.com> escreveu:

> Hi Mauro/Javier,
> 
> I can't figure out when au0828_v4l2_device_register() was added. Must be in
> Linux 4.5 as I can't find this change in Linux 4.4 This used to be a call to
> v4l2_device_register() from au0828_usb_probe(). When the code was moved, locking
> bugs are introduced.

I guess this was introduced before 4.5

> 
> Notice that au0828_v4l2_device_register() does the following in error legs:
> 
>                 mutex_unlock(&dev->lock);
>                 kfree(dev);
> 
> 
> And au0828_usb_probe() also does the same cleanup when au0828_v4l2_device_register()
> returns error:
> 
>         retval = au0828_v4l2_device_register(interface, dev);
>         if (retval) {
>                 au0828_usb_v4l2_media_release(dev);
>                 mutex_unlock(&dev->lock);
>                 kfree(dev);
>                 return retval;
>         }
> 
> We could be seeing some problems if this fails.
> 
> Please let me know if you would like a patch to fix this.

Yes, sure!

Regards,
Mauro

> 
> The following is the right fix:
> 
> diff --git a/drivers/media/usb/au0828/au0828-video.c b/drivers/media/usb/au0828/au0828-video.c
> index 32d7db9..7d0ec4c 100644
> --- a/drivers/media/usb/au0828/au0828-video.c
> +++ b/drivers/media/usb/au0828/au0828-video.c
> @@ -679,8 +679,6 @@ int au0828_v4l2_device_register(struct usb_interface *interface,
>         if (retval) {
>                 pr_err("%s() v4l2_device_register failed\n",
>                        __func__);
> -               mutex_unlock(&dev->lock);
> -               kfree(dev);
>                 return retval;
>         }
>  
> @@ -691,8 +689,6 @@ int au0828_v4l2_device_register(struct usb_interface *interface,
>         if (retval) {
>                 pr_err("%s() v4l2_ctrl_handler_init failed\n",
>                        __func__);
> -               mutex_unlock(&dev->lock);
> -               kfree(dev);
>                 return retval;
>         }
>         dev->v4l2_dev.ctrl_handler = &dev->v4l2_ctrl_hdl;
> 
> 
> thanks,
> -- Shuah
> 


-- 
Thanks,
Mauro

      reply	other threads:[~2016-03-28 18:18 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-03-28 17:08 au0828_v4l2_device_register() Shuah Khan
2016-03-28 18:18 ` Mauro Carvalho Chehab [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=20160328151810.63364106@recife.lan \
    --to=mchehab@osg.samsung.com \
    --cc=javier@osg.samsung.com \
    --cc=linux-media@vger.kernel.org \
    --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