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: refactor TIOCSSERIAL handling

Factor out the deprecated serial flags handling and tty-operation check
shared with the compat TIOCSSERIAL handler.

Signed-off-by: Johan Hovold <johan@kernel.org>
Link: https://lore.kernel.org/r/20210407095208.31838-6-johan@kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Johan Hovold and committed by
Greg Kroah-Hartman
885c77d5 1b7bc6b1

+16 -17
+16 -17
drivers/tty/tty_io.c
··· 2624 2624 return 0; 2625 2625 } 2626 2626 2627 - static int tty_tiocsserial(struct tty_struct *tty, struct serial_struct __user *ss) 2627 + static int tty_set_serial(struct tty_struct *tty, struct serial_struct *ss) 2628 2628 { 2629 2629 char comm[TASK_COMM_LEN]; 2630 - struct serial_struct v; 2631 2630 int flags; 2632 2631 2633 - if (copy_from_user(&v, ss, sizeof(*ss))) 2634 - return -EFAULT; 2635 - 2636 - flags = v.flags & ASYNC_DEPRECATED; 2632 + flags = ss->flags & ASYNC_DEPRECATED; 2637 2633 2638 2634 if (flags) 2639 2635 pr_warn_ratelimited("%s: '%s' is using deprecated serial flags (with no effect): %.8x\n", 2640 2636 __func__, get_task_comm(comm, current), flags); 2637 + 2641 2638 if (!tty->ops->set_serial) 2642 2639 return -ENOTTY; 2643 - return tty->ops->set_serial(tty, &v); 2640 + 2641 + return tty->ops->set_serial(tty, ss); 2642 + } 2643 + 2644 + static int tty_tiocsserial(struct tty_struct *tty, struct serial_struct __user *ss) 2645 + { 2646 + struct serial_struct v; 2647 + 2648 + if (copy_from_user(&v, ss, sizeof(*ss))) 2649 + return -EFAULT; 2650 + 2651 + return tty_set_serial(tty, &v); 2644 2652 } 2645 2653 2646 2654 static int tty_tiocgserial(struct tty_struct *tty, struct serial_struct __user *ss) ··· 2846 2838 static int compat_tty_tiocsserial(struct tty_struct *tty, 2847 2839 struct serial_struct32 __user *ss) 2848 2840 { 2849 - char comm[TASK_COMM_LEN]; 2850 2841 struct serial_struct32 v32; 2851 2842 struct serial_struct v; 2852 - int flags; 2853 2843 2854 2844 if (copy_from_user(&v32, ss, sizeof(*ss))) 2855 2845 return -EFAULT; ··· 2858 2852 v.port_high = v32.port_high; 2859 2853 v.iomap_base = 0; 2860 2854 2861 - flags = v.flags & ASYNC_DEPRECATED; 2862 - 2863 - if (flags) 2864 - pr_warn_ratelimited("%s: '%s' is using deprecated serial flags (with no effect): %.8x\n", 2865 - __func__, get_task_comm(comm, current), flags); 2866 - if (!tty->ops->set_serial) 2867 - return -ENOTTY; 2868 - return tty->ops->set_serial(tty, &v); 2855 + return tty_set_serial(tty, &v); 2869 2856 } 2870 2857 2871 2858 static int compat_tty_tiocgserial(struct tty_struct *tty,