Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 949bf643 authored by Fengwei Yin's avatar Fengwei Yin Committed by Greg Kroah-Hartman
Browse files

[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 <xaityyy@gmail.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent 3d48586c
Loading
Loading
Loading
Loading
+2 −0
Original line number Original line Diff line number Diff line
@@ -890,10 +890,12 @@ static void gs_close(struct tty_struct *tty, struct file *file)
	/* wait for write buffer to drain, or */
	/* wait for write buffer to drain, or */
	/* at most GS_CLOSE_TIMEOUT seconds */
	/* at most GS_CLOSE_TIMEOUT seconds */
	if (gs_buf_data_avail(port->port_write_buf) > 0) {
	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,
		wait_cond_interruptible_timeout(port->port_write_wait,
		port->port_dev == NULL
		port->port_dev == NULL
		|| gs_buf_data_avail(port->port_write_buf) == 0,
		|| gs_buf_data_avail(port->port_write_buf) == 0,
		&port->port_lock, flags, GS_CLOSE_TIMEOUT * HZ);
		&port->port_lock, flags, GS_CLOSE_TIMEOUT * HZ);
		spin_lock_irqsave(&port->port_lock, flags);
	}
	}


	/* free disconnected port on final close */
	/* free disconnected port on final close */