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

tty: remove file from tty_mode_ioctl

The only user of 'file' parameter in tty_mode_ioctl is a BUG_ON check.
Provided it never crashed for anyone, it's an overkill to pass the
parameter to tty_mode_ioctl only for this check.

If we wanted to check 'file' there, we should handle it in more graceful
way anyway. Not by a BUG == crash.

Cc: Wolfgang Grandegger <wg@grandegger.com>
Cc: Marc Kleine-Budde <mkl@pengutronix.de>
Cc: "David S. Miller" <davem@davemloft.net>
Cc: Jakub Kicinski <kuba@kernel.org>
Cc: Andreas Koensgen <ajk@comnets.uni-bremen.de>
Cc: Paul Mackerras <paulus@samba.org>
Acked-by: Marc Kleine-Budde <mkl@pengutronix.de>
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
Link: https://lore.kernel.org/r/20210914091134.17426-5-jslaby@suse.cz
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Jiri Slaby and committed by
Greg Kroah-Hartman
dcc223e8 28f194da

+8 -13
+1 -1
drivers/net/can/slcan.c
··· 691 691 return -EINVAL; 692 692 693 693 default: 694 - return tty_mode_ioctl(tty, file, cmd, arg); 694 + return tty_mode_ioctl(tty, cmd, arg); 695 695 } 696 696 } 697 697
+1 -1
drivers/net/hamradio/6pack.c
··· 732 732 break; 733 733 } 734 734 default: 735 - err = tty_mode_ioctl(tty, file, cmd, arg); 735 + err = tty_mode_ioctl(tty, cmd, arg); 736 736 } 737 737 738 738 sp_put(sp);
+1 -1
drivers/net/ppp/ppp_async.c
··· 322 322 323 323 default: 324 324 /* Try the various mode ioctls */ 325 - err = tty_mode_ioctl(tty, file, cmd, arg); 325 + err = tty_mode_ioctl(tty, cmd, arg); 326 326 } 327 327 328 328 ap_put(ap);
+1 -1
drivers/net/ppp/ppp_synctty.c
··· 314 314 break; 315 315 316 316 default: 317 - err = tty_mode_ioctl(tty, file, cmd, arg); 317 + err = tty_mode_ioctl(tty, cmd, arg); 318 318 break; 319 319 } 320 320
+1 -1
drivers/net/slip/slip.c
··· 1173 1173 /* VSV changes end */ 1174 1174 #endif 1175 1175 default: 1176 - return tty_mode_ioctl(tty, file, cmd, arg); 1176 + return tty_mode_ioctl(tty, cmd, arg); 1177 1177 } 1178 1178 } 1179 1179
+2 -6
drivers/tty/tty_ioctl.c
··· 675 675 /** 676 676 * tty_mode_ioctl - mode related ioctls 677 677 * @tty: tty for the ioctl 678 - * @file: file pointer for the tty 679 678 * @cmd: command 680 679 * @arg: ioctl argument 681 680 * ··· 683 684 * consistent mode setting. 684 685 */ 685 686 686 - int tty_mode_ioctl(struct tty_struct *tty, struct file *file, 687 - unsigned int cmd, unsigned long arg) 687 + int tty_mode_ioctl(struct tty_struct *tty, unsigned int cmd, unsigned long arg) 688 688 { 689 689 struct tty_struct *real_tty; 690 690 void __user *p = (void __user *)arg; 691 691 int ret = 0; 692 692 struct ktermios kterm; 693 - 694 - BUG_ON(file == NULL); 695 693 696 694 if (tty->driver->type == TTY_DRIVER_TYPE_PTY && 697 695 tty->driver->subtype == PTY_TYPE_MASTER) ··· 900 904 return __tty_perform_flush(tty, arg); 901 905 default: 902 906 /* Try the mode commands */ 903 - return tty_mode_ioctl(tty, file, cmd, arg); 907 + return tty_mode_ioctl(tty, cmd, arg); 904 908 } 905 909 } 906 910 EXPORT_SYMBOL(n_tty_ioctl_helper);
+1 -2
include/linux/tty.h
··· 369 369 370 370 void tty_wakeup(struct tty_struct *tty); 371 371 372 - int tty_mode_ioctl(struct tty_struct *tty, struct file *file, 373 - unsigned int cmd, unsigned long arg); 372 + int tty_mode_ioctl(struct tty_struct *tty, unsigned int cmd, unsigned long arg); 374 373 int tty_perform_flush(struct tty_struct *tty, unsigned long arg); 375 374 struct tty_struct *tty_init_dev(struct tty_driver *driver, int idx); 376 375 void tty_release_struct(struct tty_struct *tty, int idx);