Skip to contentSkip to conversation

Staging: generic_serial: fix double locking bug

PATCH In review Dan Carpenter 2 participants 2 messages Feb 28, 2011

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Staging: generic_serial: fix double locking bug

spin_lock_irqsave() is not nestable. The second time that it gets called it overwrites the "flags" variable and so IRQs can't be restored properly.

---
Oh. Crap. I don't want to adopt these drivers. But I already wrote the patch before I read the TODO file, so I'm still going to submit it.

drivers/staging/generic_serial/generic_serial.c +2 -2
index 5954ee1..466988d 100644
@@ -566,9 +566,9 @@ void gs_close(struct tty_struct * tty, struct file * filp)
 	 * line status register.
 	 */
 
-	spin_lock_irqsave(&port->driver_lock, flags);
+	spin_lock(&port->driver_lock);
 	port->rd->disable_rx_interrupts (port);
-	spin_unlock_irqrestore(&port->driver_lock, flags);
+	spin_unlock(&port->driver_lock);
 	spin_unlock_irqrestore(&port->port.lock, flags);
 
 	/* close has no way of returning "EINTR", so discard return value */
#1 lore raw
Quoted 8 lines · Dan Carpenter

spin_lock_irqsave() is not nestable. The second time that it gets called it overwrites the "flags" variable and so IRQs can't be restored properly.

---
Oh. Crap. I don't want to adopt these drivers. But I already wrote the patch before I read the TODO file, so I'm still going to submit it.

Heh, don't worry, you don't "own" them, I'll just take this fix for now and still leave them in the "abandoned" category :)

thanks,

greg k-h