Skip to contentSkip to conversation

usb: gadget: u_serial: add missing port entry locking

PATCH Superseded Greg Kroah-Hartman 1 participant 1 message Feb 27, 2019 USB

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore

Greg Kroah-Hartman

author maintainer
#0 lore raw

PATCH 1/5 usb: gadget: u_serial: add missing port entry locking

Quoted 13 lines · Michał Mirosław

gserial_alloc_line() misses locking (for a release barrier) while resetting port entry on TTY allocation failure. Fix this.

---
 drivers/usb/gadget/function/u_serial.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/usb/gadget/function/u_serial.c +0 -0
index 65f634ec7fc2..bb1e2e1d0076 100644

drivers/usb/gadget/function/u_serial.c int gserial_alloc_line(unsigned char *line_num) · line 1248

Quoted 10 lines
drivers/usb/gadget/function/u_serial.c +2 -0
@@ -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;
 	}

Should this be backported to stable kernels to resolve this issue?

thanks,

greg k-h