Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

tty: fix return value for unsupported ioctls

Drivers should return -ENOTTY ("Inappropriate I/O control operation")
when an ioctl isn't supported, while -EINVAL is used for invalid
arguments.

Fix up the TIOCMGET, TIOCMSET and TIOCGICOUNT helpers which returned
-EINVAL when a tty driver did not implement the corresponding
operations.

Note that the TIOCMGET and TIOCMSET helpers predate git and do not get a
corresponding Fixes tag below.

Fixes: d281da7ff6f7 ("tty: Make tiocgicount a handler")
Signed-off-by: Johan Hovold <johan@kernel.org>
Link: https://lore.kernel.org/r/20210407095208.31838-3-johan@kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Johan Hovold and committed by
Greg Kroah-Hartman
1b8b2086 d09845e9

+6 -6
+5 -5
drivers/tty/tty_io.c
··· 2529 2529 * @p: pointer to result 2530 2530 * 2531 2531 * Obtain the modem status bits from the tty driver if the feature 2532 - * is supported. Return -EINVAL if it is not available. 2532 + * is supported. Return -ENOTTY if it is not available. 2533 2533 * 2534 2534 * Locking: none (up to the driver) 2535 2535 */ 2536 2536 2537 2537 static int tty_tiocmget(struct tty_struct *tty, int __user *p) 2538 2538 { 2539 - int retval = -EINVAL; 2539 + int retval = -ENOTTY; 2540 2540 2541 2541 if (tty->ops->tiocmget) { 2542 2542 retval = tty->ops->tiocmget(tty); ··· 2554 2554 * @p: pointer to desired bits 2555 2555 * 2556 2556 * Set the modem status bits from the tty driver if the feature 2557 - * is supported. Return -EINVAL if it is not available. 2557 + * is supported. Return -ENOTTY if it is not available. 2558 2558 * 2559 2559 * Locking: none (up to the driver) 2560 2560 */ ··· 2566 2566 unsigned int set, clear, val; 2567 2567 2568 2568 if (tty->ops->tiocmset == NULL) 2569 - return -EINVAL; 2569 + return -ENOTTY; 2570 2570 2571 2571 retval = get_user(val, p); 2572 2572 if (retval) ··· 2606 2606 if (tty->ops->get_icount) 2607 2607 return tty->ops->get_icount(tty, icount); 2608 2608 else 2609 - return -EINVAL; 2609 + return -ENOTTY; 2610 2610 } 2611 2611 EXPORT_SYMBOL_GPL(tty_get_icount); 2612 2612
+1 -1
include/linux/tty_driver.h
··· 228 228 * 229 229 * Called when the device receives a TIOCGICOUNT ioctl. Passed a kernel 230 230 * structure to complete. This method is optional and will only be called 231 - * if provided (otherwise EINVAL will be returned). 231 + * if provided (otherwise ENOTTY will be returned). 232 232 */ 233 233 234 234 #include <linux/export.h>