Commit 58af9654 authored by Baolin Wang's avatar Baolin Wang Committed by Stefan Bader

usb: gadget: Add the gserial port checking in gs_start_tx()

BugLink: https://bugs.launchpad.net/bugs/1826212

commit 511a36d2 upstream.

When usb gadget is set gadget serial function, it will be crash in below
situation.

It will clean the 'port->port_usb' pointer in gserial_disconnect() function
when usb link is inactive, but it will release lock for disabling the endpoints
in this function. Druing the lock release period, it maybe complete one request
to issue gs_write_complete()--->gs_start_tx() function, but the 'port->port_usb'
pointer had been set NULL, thus it will be crash in gs_start_tx() function.

This patch adds the 'port->port_usb' pointer checking in gs_start_tx() function
to avoid this situation.
Signed-off-by: default avatarBaolin Wang <baolin.wang@linaro.org>
Signed-off-by: default avatarFelipe Balbi <felipe.balbi@linux.intel.com>
Signed-off-by: default avatarArnd Bergmann <arnd@arndb.de>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: default avatarStefan Bader <stefan.bader@canonical.com>
Signed-off-by: default avatarKleber Sacilotto de Souza <kleber.souza@canonical.com>
parent efa91488
...@@ -361,10 +361,15 @@ __acquires(&port->port_lock) ...@@ -361,10 +361,15 @@ __acquires(&port->port_lock)
*/ */
{ {
struct list_head *pool = &port->write_pool; struct list_head *pool = &port->write_pool;
struct usb_ep *in = port->port_usb->in; struct usb_ep *in;
int status = 0; int status = 0;
bool do_tty_wake = false; bool do_tty_wake = false;
if (!port->port_usb)
return status;
in = port->port_usb->in;
while (!port->write_busy && !list_empty(pool)) { while (!port->write_busy && !list_empty(pool)) {
struct usb_request *req; struct usb_request *req;
int len; int len;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment