Skip to content

Commit 3d71fe0

Browse files
Alan-Coxgregkh
authored andcommitted
USB: io_ti: lock mcr and msr shadows properly
Signed-off-by: Alan Cox <alan@redhat.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
1 parent 04ca89d commit 3d71fe0

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

‎drivers/usb/serial/io_ti.c‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2559,9 +2559,11 @@ static int edge_tiocmset (struct usb_serial_port *port, struct file *file, unsig
25592559
{
25602560
struct edgeport_port *edge_port = usb_get_serial_port_data(port);
25612561
unsigned int mcr;
2562+
unsigned long flags;
25622563

25632564
dbg("%s - port %d", __FUNCTION__, port->number);
25642565

2566+
spin_lock_irqsave(&edge_port->ep_lock, flags);
25652567
mcr = edge_port->shadow_mcr;
25662568
if (set & TIOCM_RTS)
25672569
mcr |= MCR_RTS;
@@ -2578,6 +2580,7 @@ static int edge_tiocmset (struct usb_serial_port *port, struct file *file, unsig
25782580
mcr &= ~MCR_LOOPBACK;
25792581

25802582
edge_port->shadow_mcr = mcr;
2583+
spin_unlock_irqrestore(&edge_port->ep_lock, flags);
25812584

25822585
TIRestoreMCR (edge_port, mcr);
25832586

@@ -2590,9 +2593,12 @@ static int edge_tiocmget(struct usb_serial_port *port, struct file *file)
25902593
unsigned int result = 0;
25912594
unsigned int msr;
25922595
unsigned int mcr;
2596+
unsigned long flags;
25932597

25942598
dbg("%s - port %d", __FUNCTION__, port->number);
25952599

2600+
spin_lock_irqsave(&edge_port->ep_lock, flags);
2601+
25962602
msr = edge_port->shadow_msr;
25972603
mcr = edge_port->shadow_mcr;
25982604
result = ((mcr & MCR_DTR) ? TIOCM_DTR: 0) /* 0x002 */
@@ -2604,6 +2610,7 @@ static int edge_tiocmget(struct usb_serial_port *port, struct file *file)
26042610

26052611

26062612
dbg("%s -- %x", __FUNCTION__, result);
2613+
spin_unlock_irqrestore(&edge_port->ep_lock, flags);
26072614

26082615
return result;
26092616
}

0 commit comments

Comments
 (0)