usb: gadget: u_serial: add missing port entry locking
commit daf82bd24e308c5a83758047aff1bd81edda4f11 upstream. gserial_alloc_line() misses locking (for a release barrier) while resetting port entry on TTY allocation failure. Fix this. Cc: stable@vger.kernel.org Signed-off-by: Michał Mirosław <mirq-linux@rere.qmqm.pl> Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Tested-by: Ladislav Michl <ladis@linux-mips.org> Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
1b4ce5fca0
commit
f2278b83bb
1 changed files with 2 additions and 0 deletions
|
@ -1137,8 +1137,10 @@ int gserial_alloc_line(unsigned char *line_num)
|
||||||
__func__, port_num, PTR_ERR(tty_dev));
|
__func__, port_num, PTR_ERR(tty_dev));
|
||||||
|
|
||||||
ret = PTR_ERR(tty_dev);
|
ret = PTR_ERR(tty_dev);
|
||||||
|
mutex_lock(&ports[port_num].lock);
|
||||||
port = ports[port_num].port;
|
port = ports[port_num].port;
|
||||||
ports[port_num].port = NULL;
|
ports[port_num].port = NULL;
|
||||||
|
mutex_unlock(&ports[port_num].lock);
|
||||||
gserial_free_port(port);
|
gserial_free_port(port);
|
||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue