From: Fengwei Yin Date: Fri, 18 Nov 2005 02:35:36 +0000 (+0800) Subject: [PATCH] USB: One potential problem in gadget/serial.c X-Git-Tag: v2.6.16-rc1~474^2~22^2~10^2~47 X-Git-Url: http://pilppa.com/gitweb/?a=commitdiff_plain;h=949bf6431189c62eeebd3b52201406ba9978f525;p=linux-2.6-omap-h63xx.git [PATCH] USB: One potential problem in gadget/serial.c It looks like that the gs_serial module maybe sleep with spinlock in gs_close. Sometimes, system hang when I remove the gs_serial module. From: Fengwei Yin Signed-off-by: Greg Kroah-Hartman --- diff --git a/drivers/usb/gadget/serial.c b/drivers/usb/gadget/serial.c index b35ac6d334f..65e084a2c87 100644 --- a/drivers/usb/gadget/serial.c +++ b/drivers/usb/gadget/serial.c @@ -890,10 +890,12 @@ static void gs_close(struct tty_struct *tty, struct file *file) /* wait for write buffer to drain, or */ /* at most GS_CLOSE_TIMEOUT seconds */ if (gs_buf_data_avail(port->port_write_buf) > 0) { + spin_unlock_irqrestore(&port->port_lock, flags); wait_cond_interruptible_timeout(port->port_write_wait, port->port_dev == NULL || gs_buf_data_avail(port->port_write_buf) == 0, &port->port_lock, flags, GS_CLOSE_TIMEOUT * HZ); + spin_lock_irqsave(&port->port_lock, flags); } /* free disconnected port on final close */