diff mbox series

[v2,1/5] usb: gadget: u_serial: add missing port entry locking

Message ID 5365749544fb509adeaca88754726eb14070b7b4.1551259482.git.mirq-linux@rere.qmqm.pl (mailing list archive)
State Superseded
Headers show
Series usb: gadget: u_serial: console for multiple ports | expand

Commit Message

Michał Mirosław Feb. 27, 2019, 9:29 a.m. UTC
gserial_alloc_line() misses locking (for a release barrier) while
resetting port entry on TTY allocation failure. Fix this.

Signed-off-by: Michał Mirosław <mirq-linux@rere.qmqm.pl>
---
  v2: no changes
---
 drivers/usb/gadget/function/u_serial.c | 2 ++
 1 file changed, 2 insertions(+)

Comments

Greg KH Feb. 27, 2019, 9:34 a.m. UTC | #1
On Wed, Feb 27, 2019 at 10:29:37AM +0100, Michał Mirosław wrote:
> gserial_alloc_line() misses locking (for a release barrier) while
> resetting port entry on TTY allocation failure. Fix this.
> 
> Signed-off-by: Michał Mirosław <mirq-linux@rere.qmqm.pl>
> ---
>   v2: no changes

Shouldn't you have added a:
Cc: stable <stable@vger.kernel.org>

to this?  :)
diff mbox series

Patch

diff --git a/drivers/usb/gadget/function/u_serial.c b/drivers/usb/gadget/function/u_serial.c
index 65f634ec7fc2..bb1e2e1d0076 100644
--- a/drivers/usb/gadget/function/u_serial.c
+++ b/drivers/usb/gadget/function/u_serial.c
@@ -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;
 	}