public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] [media] lirc_imon: do not leave imon_probe() with mutex held
@ 2015-11-14 18:17 Alexey Khoroshilov
  2015-11-16 15:04 ` Dan Carpenter
  0 siblings, 1 reply; 2+ messages in thread
From: Alexey Khoroshilov @ 2015-11-14 18:17 UTC (permalink / raw)
  To: Jarod Wilson, Mauro Carvalho Chehab
  Cc: Alexey Khoroshilov, Greg Kroah-Hartman, linux-media, devel,
	linux-kernel, ldv-project

Commit af8a819a2513 ("[media] lirc_imon: simplify error handling code")
lost mutex_unlock(&context->ctx_lock), so imon_probe() exits with
the context->ctx_lock mutex acquired.

The patch adds mutex_unlock(&context->ctx_lock) back.

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

Signed-off-by: Alexey Khoroshilov <khoroshilov@ispras.ru>
Fixes: af8a819a2513 ("[media] lirc_imon: simplify error handling code")
---
 drivers/staging/media/lirc/lirc_imon.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/staging/media/lirc/lirc_imon.c b/drivers/staging/media/lirc/lirc_imon.c
index 534b8103ae80..ff1926ca1f96 100644
--- a/drivers/staging/media/lirc/lirc_imon.c
+++ b/drivers/staging/media/lirc/lirc_imon.c
@@ -885,12 +885,14 @@ static int imon_probe(struct usb_interface *interface,
 		vendor, product, ifnum, usbdev->bus->busnum, usbdev->devnum);
 
 	/* Everything went fine. Just unlock and return retval (with is 0) */
+	mutex_unlock(&context->ctx_lock);
 	goto driver_unlock;
 
 unregister_lirc:
 	lirc_unregister_driver(driver->minor);
 
 free_tx_urb:
+	mutex_unlock(&context->ctx_lock);
 	usb_free_urb(tx_urb);
 
 free_rx_urb:
-- 
1.9.1


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

* Re: [PATCH] [media] lirc_imon: do not leave imon_probe() with mutex held
  2015-11-14 18:17 [PATCH] [media] lirc_imon: do not leave imon_probe() with mutex held Alexey Khoroshilov
@ 2015-11-16 15:04 ` Dan Carpenter
  0 siblings, 0 replies; 2+ messages in thread
From: Dan Carpenter @ 2015-11-16 15:04 UTC (permalink / raw)
  To: Alexey Khoroshilov
  Cc: Jarod Wilson, Mauro Carvalho Chehab, devel, ldv-project,
	Greg Kroah-Hartman, linux-kernel, linux-media

On Sat, Nov 14, 2015 at 09:17:56PM +0300, Alexey Khoroshilov wrote:
> Commit af8a819a2513 ("[media] lirc_imon: simplify error handling code")
> lost mutex_unlock(&context->ctx_lock), so imon_probe() exits with
> the context->ctx_lock mutex acquired.
> 
> The patch adds mutex_unlock(&context->ctx_lock) back.
> 
> Found by Linux Driver Verification project (linuxtesting.org).
> 
> Signed-off-by: Alexey Khoroshilov <khoroshilov@ispras.ru>
> Fixes: af8a819a2513 ("[media] lirc_imon: simplify error handling code")

Hm...  This patch is from June and it totally breaks the driver.  It's
dissapointing that no one reported this bug.

> ---
>  drivers/staging/media/lirc/lirc_imon.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/drivers/staging/media/lirc/lirc_imon.c b/drivers/staging/media/lirc/lirc_imon.c
> index 534b8103ae80..ff1926ca1f96 100644
> --- a/drivers/staging/media/lirc/lirc_imon.c
> +++ b/drivers/staging/media/lirc/lirc_imon.c
> @@ -885,12 +885,14 @@ static int imon_probe(struct usb_interface *interface,
>  		vendor, product, ifnum, usbdev->bus->busnum, usbdev->devnum);
>  
>  	/* Everything went fine. Just unlock and return retval (with is 0) */
> +	mutex_unlock(&context->ctx_lock);
>  	goto driver_unlock;
>  
>  unregister_lirc:
>  	lirc_unregister_driver(driver->minor);
>  
>  free_tx_urb:
> +	mutex_unlock(&context->ctx_lock);
>  	usb_free_urb(tx_urb);

Now the label name doesn't make sense.  Also this unlock isn't needed
because we are just going to free context anyway.

regards,
dan carpenter


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

end of thread, other threads:[~2015-11-16 15:05 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-11-14 18:17 [PATCH] [media] lirc_imon: do not leave imon_probe() with mutex held Alexey Khoroshilov
2015-11-16 15:04 ` Dan Carpenter

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