tty: remove file from tty_mode_ioctl
authorJiri Slaby <jslaby@suse.cz>
Tue, 14 Sep 2021 09:11:23 +0000 (11:11 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 22 Sep 2021 14:59:13 +0000 (16:59 +0200)
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>
drivers/net/can/slcan.c
drivers/net/hamradio/6pack.c
drivers/net/ppp/ppp_async.c
drivers/net/ppp/ppp_synctty.c
drivers/net/slip/slip.c
drivers/tty/tty_ioctl.c
include/linux/tty.h

index 012da4b8abe0a466d95e0ae9c6f52a94fb83d584..9a4ebda30510ef2f0ea1de1ab3a620e6514938e4 100644 (file)
@@ -691,7 +691,7 @@ static int slcan_ioctl(struct tty_struct *tty, struct file *file,
                return -EINVAL;
 
        default:
-               return tty_mode_ioctl(tty, file, cmd, arg);
+               return tty_mode_ioctl(tty, cmd, arg);
        }
 }
 
index 8fe8887d506a3e269d34542b75486624bdc03a3e..05404f7a32047fb890a5da6da765979576a256f4 100644 (file)
@@ -732,7 +732,7 @@ static int sixpack_ioctl(struct tty_struct *tty, struct file *file,
                        break;
                }
        default:
-               err = tty_mode_ioctl(tty, file, cmd, arg);
+               err = tty_mode_ioctl(tty, cmd, arg);
        }
 
        sp_put(sp);
index 78ec1bcebc4fcb23b6c66beb406476c5fc640818..6492523fc234858074d814f2d42655e022b00f0a 100644 (file)
@@ -322,7 +322,7 @@ ppp_asynctty_ioctl(struct tty_struct *tty, struct file *file,
 
        default:
                /* Try the various mode ioctls */
-               err = tty_mode_ioctl(tty, file, cmd, arg);
+               err = tty_mode_ioctl(tty, cmd, arg);
        }
 
        ap_put(ap);
index c249db7c466a6d9182d6cf8bcb972714589275a3..ebbfea0e1140b274ffd68b48baa8e209071223c0 100644 (file)
@@ -314,7 +314,7 @@ ppp_synctty_ioctl(struct tty_struct *tty, struct file *file,
                break;
 
        default:
-               err = tty_mode_ioctl(tty, file, cmd, arg);
+               err = tty_mode_ioctl(tty, cmd, arg);
                break;
        }
 
index 8be9d0c351b5bbd29e6eaec917fb62ea1e6d39c6..9f3b4c1aa5ce888091f6239565cd7e60701dbabc 100644 (file)
@@ -1173,7 +1173,7 @@ static int slip_ioctl(struct tty_struct *tty, struct file *file,
        /* VSV changes end */
 #endif
        default:
-               return tty_mode_ioctl(tty, file, cmd, arg);
+               return tty_mode_ioctl(tty, cmd, arg);
        }
 }
 
index 507a25d692bb1ffe21e07de915600bf44f5096d5..99a29d72d2943eb08f56d44fb0b9269694d3fc50 100644 (file)
@@ -675,7 +675,6 @@ static int tty_change_softcar(struct tty_struct *tty, int arg)
 /**
  *     tty_mode_ioctl          -       mode related ioctls
  *     @tty: tty for the ioctl
- *     @file: file pointer for the tty
  *     @cmd: command
  *     @arg: ioctl argument
  *
@@ -684,16 +683,13 @@ static int tty_change_softcar(struct tty_struct *tty, int arg)
  *     consistent mode setting.
  */
 
-int tty_mode_ioctl(struct tty_struct *tty, struct file *file,
-                       unsigned int cmd, unsigned long arg)
+int tty_mode_ioctl(struct tty_struct *tty, unsigned int cmd, unsigned long arg)
 {
        struct tty_struct *real_tty;
        void __user *p = (void __user *)arg;
        int ret = 0;
        struct ktermios kterm;
 
-       BUG_ON(file == NULL);
-
        if (tty->driver->type == TTY_DRIVER_TYPE_PTY &&
            tty->driver->subtype == PTY_TYPE_MASTER)
                real_tty = tty->link;
@@ -904,7 +900,7 @@ int n_tty_ioctl_helper(struct tty_struct *tty, struct file *file,
                return __tty_perform_flush(tty, arg);
        default:
                /* Try the mode commands */
-               return tty_mode_ioctl(tty, file, cmd, arg);
+               return tty_mode_ioctl(tty, cmd, arg);
        }
 }
 EXPORT_SYMBOL(n_tty_ioctl_helper);
index 15453b0c4081338d49a954e4af4f46dee7ef4f9a..5e73f577c2b4f5a0fcb7ecafb97b191d67d616f6 100644 (file)
@@ -369,8 +369,7 @@ int tty_set_termios(struct tty_struct *tty, struct ktermios *kt);
 
 void tty_wakeup(struct tty_struct *tty);
 
-int tty_mode_ioctl(struct tty_struct *tty, struct file *file,
-                       unsigned int cmd, unsigned long arg);
+int tty_mode_ioctl(struct tty_struct *tty, unsigned int cmd, unsigned long arg);
 int tty_perform_flush(struct tty_struct *tty, unsigned long arg);
 struct tty_struct *tty_init_dev(struct tty_driver *driver, int idx);
 void tty_release_struct(struct tty_struct *tty, int idx);