Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1289872 > unrolled thread

[PATCH 1/1] USB: inode.c: fix unbalanced spin_lock in ep0_write

Started byDavid Eccher <d.eccher@gmail.com>
First post2015-12-11 21:00 +0100
Last post2015-12-11 22:00 +0100
Articles 4 — 3 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH 1/1] USB: inode.c: fix unbalanced spin_lock in ep0_write David Eccher <d.eccher@gmail.com> - 2015-12-11 21:00 +0100
    Re: [PATCH 1/1] USB: inode.c: fix unbalanced spin_lock in ep0_write Al Viro <viro@ZenIV.linux.org.uk> - 2015-12-11 21:20 +0100
      Re: [PATCH 1/1] USB: inode.c: fix unbalanced spin_lock in ep0_write David Eccher <d.eccher@gmail.com> - 2015-12-11 22:20 +0100
    Re: [PATCH 1/1] USB: inode.c: fix unbalanced spin_lock in ep0_write Sergei Shtylyov <sergei.shtylyov@cogentembedded.com> - 2015-12-11 22:00 +0100

#1289872 — [PATCH 1/1] USB: inode.c: fix unbalanced spin_lock in ep0_write

FromDavid Eccher <d.eccher@gmail.com>
Date2015-12-11 21:00 +0100
Subject[PATCH 1/1] USB: inode.c: fix unbalanced spin_lock in ep0_write
Message-ID<qEC1c-q7-5@gated-at.bofh.it>
Fix bad unlock balance: ep0_write enter with the locks locked from inode.c:1769,
hence it must exit with spinlock held to avoid double unlock in dev_config.

Signed-off-by: David Eccher <d.eccher@gmail.com>
---
 drivers/usb/gadget/legacy/inode.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/usb/gadget/legacy/inode.c b/drivers/usb/gadget/legacy/inode.c
index f454c7a..b968c25 100644
--- a/drivers/usb/gadget/legacy/inode.c
+++ b/drivers/usb/gadget/legacy/inode.c
@@ -1144,6 +1144,7 @@ ep0_write (struct file *fd, const char __user *buf, size_t len, loff_t *ptr)
 				} else
 					retval = len;
 
+				spin_lock_irq (&dev->lock);
 				return retval;
 			}
 
-- 
1.8.1.2

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [next] | [standalone]


#1289881

FromAl Viro <viro@ZenIV.linux.org.uk>
Date2015-12-11 21:20 +0100
Message-ID<qECkx-LZ-5@gated-at.bofh.it>
In reply to#1289872
On Fri, Dec 11, 2015 at 08:56:26PM +0100, David Eccher wrote:
> Fix bad unlock balance: ep0_write enter with the locks locked from inode.c:1769,
> hence it must exit with spinlock held to avoid double unlock in dev_config.

*Ugh*

Just take that spinlock before the if (retval < 0) and don't drop it after
clear_req(), then...
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1289904

FromDavid Eccher <d.eccher@gmail.com>
Date2015-12-11 22:20 +0100
Message-ID<qEDgB-1n0-1@gated-at.bofh.it>
In reply to#1289881
On Fri, Dec 11, 2015 at 9:11 PM, Al Viro <viro@zeniv.linux.org.uk> wrote:
>
> On Fri, Dec 11, 2015 at 08:56:26PM +0100, David Eccher wrote:
> > Fix bad unlock balance: ep0_write enter with the locks locked from inode.c:1769,
> > hence it must exit with spinlock held to avoid double unlock in dev_config.
>
> *Ugh*
>
> Just take that spinlock before the if (retval < 0) and don't drop it after
> clear_req(), then...

Oh, yeah good point, I'll send a v2...and test the patch thru
checkpatch.pl, sorry



-- 
David Eccher
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1289894

FromSergei Shtylyov <sergei.shtylyov@cogentembedded.com>
Date2015-12-11 22:00 +0100
Message-ID<qECXg-10Z-9@gated-at.bofh.it>
In reply to#1289872
Hello.

On 12/11/2015 10:56 PM, David Eccher wrote:

> Fix bad unlock balance: ep0_write enter with the locks locked from inode.c:1769,
> hence it must exit with spinlock held to avoid double unlock in dev_config.
>
> Signed-off-by: David Eccher <d.eccher@gmail.com>
> ---
>   drivers/usb/gadget/legacy/inode.c | 1 +
>   1 file changed, 1 insertion(+)
>
> diff --git a/drivers/usb/gadget/legacy/inode.c b/drivers/usb/gadget/legacy/inode.c
> index f454c7a..b968c25 100644
> --- a/drivers/usb/gadget/legacy/inode.c
> +++ b/drivers/usb/gadget/legacy/inode.c
> @@ -1144,6 +1144,7 @@ ep0_write (struct file *fd, const char __user *buf, size_t len, loff_t *ptr)
>   				} else
>   					retval = len;
>
> +				spin_lock_irq (&dev->lock);

    I guess you hadn't run the patch thru scripts/checkpatch.pl?

MBR, Sergei

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web