public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] [media] au0828: fix double free in au0828_usb_probe()
@ 2016-04-22 22:05 Alexey Khoroshilov
  2016-04-25 14:20 ` Shuah Khan
  0 siblings, 1 reply; 2+ messages in thread
From: Alexey Khoroshilov @ 2016-04-22 22:05 UTC (permalink / raw)
  To: Mauro Carvalho Chehab, Shuah Khan
  Cc: Alexey Khoroshilov, linux-media, linux-kernel, ldv-project

In case of failure au0828_v4l2_device_register() deallocates dev
and returns error code to au0828_usb_probe(), which also
calls kfree(dev) on a failure path.

The patch removes duplicated code from au0828_v4l2_device_register().

Found by Linux Driver Verification project (linuxtesting.org).

Signed-off-by: Alexey Khoroshilov <khoroshilov@ispras.ru>
---
 drivers/media/usb/au0828/au0828-video.c | 4 ----
 1 file changed, 4 deletions(-)

diff --git a/drivers/media/usb/au0828/au0828-video.c b/drivers/media/usb/au0828/au0828-video.c
index 32d7db96479c..7d0ec4cb248c 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;
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] [media] au0828: fix double free in au0828_usb_probe()
  2016-04-22 22:05 [PATCH] [media] au0828: fix double free in au0828_usb_probe() Alexey Khoroshilov
@ 2016-04-25 14:20 ` Shuah Khan
  0 siblings, 0 replies; 2+ messages in thread
From: Shuah Khan @ 2016-04-25 14:20 UTC (permalink / raw)
  To: Alexey Khoroshilov, Mauro Carvalho Chehab
  Cc: linux-media, linux-kernel, ldv-project, Shuah Khan

On 04/22/2016 04:05 PM, Alexey Khoroshilov wrote:
> In case of failure au0828_v4l2_device_register() deallocates dev
> and returns error code to au0828_usb_probe(), which also
> calls kfree(dev) on a failure path.
> 
> The patch removes duplicated code from au0828_v4l2_device_register().
> 
> Found by Linux Driver Verification project (linuxtesting.org).
> 
> Signed-off-by: Alexey Khoroshilov <khoroshilov@ispras.ru>

I sent a fix in for this a few weeks ago:

https://lkml.org/lkml/2016/3/28/453

thanks,
-- Shuah

> ---
>  drivers/media/usb/au0828/au0828-video.c | 4 ----
>  1 file changed, 4 deletions(-)
> 
> diff --git a/drivers/media/usb/au0828/au0828-video.c b/drivers/media/usb/au0828/au0828-video.c
> index 32d7db96479c..7d0ec4cb248c 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;
> 

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2016-04-25 14:20 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-04-22 22:05 [PATCH] [media] au0828: fix double free in au0828_usb_probe() Alexey Khoroshilov
2016-04-25 14:20 ` Shuah Khan

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox