Commit 6b447f04a9aecdf2a30c1a97e4b034ac7931bb70
Committed by
Linus Torvalds
1 parent
eeb4613436
tty: Drop the lock_kernel in the private ioctl hook
We don't need the BKL here any more so it can go. In a couple of spots the driver requirements are not clear so push the lock down into the driver. Signed-off-by: Alan Cox <alan@redhat.com> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Showing 5 changed files with 14 additions and 8 deletions Side-by-side Diff
drivers/usb/serial/ftdi_sio.c
... | ... | @@ -1054,6 +1054,8 @@ |
1054 | 1054 | |
1055 | 1055 | if (copy_from_user(&new_serial, newinfo, sizeof(new_serial))) |
1056 | 1056 | return -EFAULT; |
1057 | + | |
1058 | + lock_kernel(); | |
1057 | 1059 | old_priv = *priv; |
1058 | 1060 | |
1059 | 1061 | /* Do error checking and permission checking */ |
1060 | 1062 | |
... | ... | @@ -1069,8 +1071,10 @@ |
1069 | 1071 | } |
1070 | 1072 | |
1071 | 1073 | if ((new_serial.baud_base != priv->baud_base) && |
1072 | - (new_serial.baud_base < 9600)) | |
1074 | + (new_serial.baud_base < 9600)) { | |
1075 | + unlock_kernel(); | |
1073 | 1076 | return -EINVAL; |
1077 | + } | |
1074 | 1078 | |
1075 | 1079 | /* Make the changes - these are privileged changes! */ |
1076 | 1080 | |
1077 | 1081 | |
... | ... | @@ -1098,8 +1102,11 @@ |
1098 | 1102 | (priv->flags & ASYNC_SPD_MASK)) || |
1099 | 1103 | (((priv->flags & ASYNC_SPD_MASK) == ASYNC_SPD_CUST) && |
1100 | 1104 | (old_priv.custom_divisor != priv->custom_divisor))) { |
1105 | + unlock_kernel(); | |
1101 | 1106 | change_speed(tty, port); |
1102 | 1107 | } |
1108 | + else | |
1109 | + unlock_kernel(); | |
1103 | 1110 | return 0; |
1104 | 1111 | |
1105 | 1112 | } /* set_serial_info */ |
drivers/usb/serial/kl5kusb105.c
drivers/usb/serial/mct_u232.c
... | ... | @@ -721,10 +721,10 @@ |
721 | 721 | |
722 | 722 | spin_lock_irqsave(&priv->lock, flags); |
723 | 723 | lcr = priv->last_lcr; |
724 | - spin_unlock_irqrestore(&priv->lock, flags); | |
725 | 724 | |
726 | 725 | if (break_state) |
727 | 726 | lcr |= MCT_U232_SET_BREAK; |
727 | + spin_unlock_irqrestore(&priv->lock, flags); | |
728 | 728 | |
729 | 729 | mct_u232_set_line_ctrl(serial, lcr); |
730 | 730 | } /* mct_u232_break_ctl */ |
drivers/usb/serial/mos7840.c
... | ... | @@ -1343,6 +1343,7 @@ |
1343 | 1343 | else |
1344 | 1344 | data = mos7840_port->shadowLCR & ~LCR_SET_BREAK; |
1345 | 1345 | |
1346 | + /* FIXME: no locking on shadowLCR anywhere in driver */ | |
1346 | 1347 | mos7840_port->shadowLCR = data; |
1347 | 1348 | dbg("mcs7840_break mos7840_port->shadowLCR is %x\n", |
1348 | 1349 | mos7840_port->shadowLCR); |
1349 | 1350 | |
... | ... | @@ -2214,10 +2215,12 @@ |
2214 | 2215 | break; |
2215 | 2216 | } |
2216 | 2217 | |
2218 | + lock_kernel(); | |
2217 | 2219 | mos7840_port->shadowMCR = mcr; |
2218 | 2220 | |
2219 | 2221 | Data = mos7840_port->shadowMCR; |
2220 | 2222 | status = mos7840_set_uart_reg(port, MODEM_CONTROL_REGISTER, Data); |
2223 | + unlock_kernel(); | |
2221 | 2224 | if (status < 0) { |
2222 | 2225 | dbg("setting MODEM_CONTROL_REGISTER Failed\n"); |
2223 | 2226 | return -1; |
drivers/usb/serial/usb-serial.c
... | ... | @@ -382,9 +382,7 @@ |
382 | 382 | /* pass on to the driver specific version of this function |
383 | 383 | if it is available */ |
384 | 384 | if (port->serial->type->ioctl) { |
385 | - lock_kernel(); | |
386 | 385 | retval = port->serial->type->ioctl(tty, file, cmd, arg); |
387 | - unlock_kernel(); | |
388 | 386 | } else |
389 | 387 | retval = -ENOIOCTLCMD; |
390 | 388 | return retval; |
391 | 389 | |
... | ... | @@ -413,11 +411,8 @@ |
413 | 411 | WARN_ON(!port->port.count); |
414 | 412 | /* pass on to the driver specific version of this function |
415 | 413 | if it is available */ |
416 | - if (port->serial->type->break_ctl) { | |
417 | - lock_kernel(); | |
414 | + if (port->serial->type->break_ctl) | |
418 | 415 | port->serial->type->break_ctl(tty, break_state); |
419 | - unlock_kernel(); | |
420 | - } | |
421 | 416 | return 0; |
422 | 417 | } |
423 | 418 |