Skip to contentSkip to conversation

USB: inode.c: fix unbalanced spin_lock in ep0_write

PATCH Superseded David Eccher 3 participants 4 messages Dec 11, 2015 USB

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

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

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.

---
 drivers/usb/gadget/legacy/inode.c | 1 +
 1 file changed, 1 insertion(+)
drivers/usb/gadget/legacy/inode.c +1 -0
index f454c7a..b968c25 100644
@@ -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;
 			}
 
Signature · 1 line
1.8.1.2
#1 lore raw
Quoted 2 lines · David Eccher

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...

#2 lore raw
Quoted 9 lines · Al Viro
Quoted 2 lines · David Eccher

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

Signature · 1 line
David Eccher
#3 lore raw
In reply to David Eccher

Hello.

Quoted 13 lines · David Eccher

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.

---
  drivers/usb/gadget/legacy/inode.c | 1 +
  1 file changed, 1 insertion(+)
drivers/usb/gadget/legacy/inode.c +0 -0
index f454c7a..b968c25 100644

drivers/usb/gadget/legacy/inode.c ep0_write (struct file *fd, const char __user *buf, size_t len, loff_t *ptr) · line 1147

Quoted 4 lines
drivers/usb/gadget/legacy/inode.c +1 -0
@@ -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