Skip to content

Commit

Permalink
usb: gadget: serial: fix oops when data rx'd after close
Browse files Browse the repository at this point in the history
When the gadget serial device has no associated TTY, do not pass any
received data into the TTY layer for processing; simply drop it instead.
This prevents the TTY layer from calling back into the gadget serial
driver, which will then crash in e.g. gs_write_room() due to lack of
gadget serial device to TTY association (i.e. a NULL pointer dereference).

Signed-off-by: Stephen Warren <[email protected]>
Signed-off-by: Felipe Balbi <[email protected]>
  • Loading branch information
nvswarren authored and Felipe Balbi committed Aug 18, 2017
1 parent afd7fd8 commit daa35bd
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion drivers/usb/gadget/function/u_serial.c
Original file line number Diff line number Diff line change
Expand Up @@ -537,7 +537,7 @@ static void gs_rx_push(unsigned long _port)
}

/* push data to (open) tty */
if (req->actual) {
if (req->actual && tty) {
char *packet = req->buf;
unsigned size = req->actual;
unsigned n;
Expand Down

0 comments on commit daa35bd

Please sign in to comment.