Skip to content

Commit

Permalink
usb: gadget: u_serial: add missing port entry locking
Browse files Browse the repository at this point in the history
gserial_alloc_line() misses locking (for a release barrier) while
resetting port entry on TTY allocation failure. Fix this.

Cc: [email protected]
Signed-off-by: Michał Mirosław <[email protected]>
Reviewed-by: Greg Kroah-Hartman <[email protected]>
Tested-by: Ladislav Michl <[email protected]>
Signed-off-by: Felipe Balbi <[email protected]>
  • Loading branch information
osctobe authored and Felipe Balbi committed Oct 22, 2019
1 parent 9ba3aca commit daf82bd
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions drivers/usb/gadget/function/u_serial.c
Original file line number Diff line number Diff line change
Expand Up @@ -1239,8 +1239,10 @@ int gserial_alloc_line(unsigned char *line_num)
__func__, port_num, PTR_ERR(tty_dev));

ret = PTR_ERR(tty_dev);
mutex_lock(&ports[port_num].lock);
port = ports[port_num].port;
ports[port_num].port = NULL;
mutex_unlock(&ports[port_num].lock);
gserial_free_port(port);
goto err;
}
Expand Down

0 comments on commit daf82bd

Please sign in to comment.