Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp493579pxb; Tue, 14 Sep 2021 02:13:06 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwrkiMvzhp80KHvnp6iUXM74NHeO28t57GI5gJZrIL4lOq9/luNoU3PndW8zr/gbMQ/axdK X-Received: by 2002:a05:6e02:1112:: with SMTP id u18mr11802492ilk.75.1631610786000; Tue, 14 Sep 2021 02:13:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631610785; cv=none; d=google.com; s=arc-20160816; b=FFZuZDuW65BUY395YvghzFfpbulhCA5W7cELe50T0Wng+Rec6pguuWkNYQiTr//StD nCZ//dEjkuZobm7GLw810Q9JcdAmcd/kd18zTCwnXyPHDg4lWoJq7xDT7bEW86vHq65T WaeJw/BstecjZfBMhUIMqYumPTF0HPnHXxd45ATfzu2zxd+iqtm0DHXSKIfTOk+R2BZn zlhkaAN0x0MGu3UA5ZGsh/OoYsjZkSpJjRfgv8OSsRC6OlcYNNKHBEMytCRXMuW9zkyn sp4lFE5I2xTNhg4wZXCEwB7oHjWSCqjLEzwYzNWVXIuUqD0MVHTC2JRI8ZxRfAT6y2xL 9fpg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:dkim-signature; bh=w+eDAVcK/wYcv9BVgAvQDXyn91WVx/j7lKfny9JvPug=; b=oBtVhqxb/HAH8cXmZADLDHgP3I7atCwHq30jP55sKFuDo3wHAJqUXC1GKgWyZF+EIX 4/QD0n0Nl2HyCMhHYlo6vGhaQdx/wX/9Hj2ywJd1cVwk72WLlVIn3V0l2+Z/j+uZmI4N +yzCMGHh0ptpt2ludMSntOPbk4QMWcAXZBLl1zJeGDEpifptl7M5mA89fdiS9JpYWMpA Qb29iMFq5LItZ3l3riCBbFnMVtfhbeyvhP8FIA1eXw8Y2DIZ5FFZalGgyPFJowkP9Bpr ePzKGm96tQGrxCpyqQTDG77sYw8ELo36gySnQZ67pWbfp3bp8wuPgtgtfQOjamo1oJL2 UYzw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=JrZo4Du8; dkim=neutral (no key) header.i=@suse.cz; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id e4si1040382ili.160.2021.09.14.02.12.53; Tue, 14 Sep 2021 02:13:05 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=JrZo4Du8; dkim=neutral (no key) header.i=@suse.cz; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230508AbhINJNG (ORCPT + 99 others); Tue, 14 Sep 2021 05:13:06 -0400 Received: from smtp-out2.suse.de ([195.135.220.29]:43314 "EHLO smtp-out2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229739AbhINJMy (ORCPT ); Tue, 14 Sep 2021 05:12:54 -0400 Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out2.suse.de (Postfix) with ESMTP id 6F338200E0; Tue, 14 Sep 2021 09:11:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1631610696; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=w+eDAVcK/wYcv9BVgAvQDXyn91WVx/j7lKfny9JvPug=; b=JrZo4Du8EpRuoMd+9AKewDxaR8EzF/HT8EN4Kwtxiy07n7924gDq2V8hR3tEoJXcaBtZtO fC8t4G5+LFRqS0++mscKmqzupBgvFXhFpwhuxpUEvXlmfT1PXlm+ZnBbUc0Rx76cIMsjQX x6Xqiq4T99uL7Gjm3YT+jm0LSjpLa64= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1631610696; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=w+eDAVcK/wYcv9BVgAvQDXyn91WVx/j7lKfny9JvPug=; b=VLMBcG0NjAUronUzkB9uGW0pmX8w0CwJKiPvHqLEjBGDGxolOSJ76P/Hc33to6KzHDfnwf mnp20bkCR9S1YUBw== Received: from localhost.localdomain (unknown [10.100.201.122]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by relay2.suse.de (Postfix) with ESMTPS id 2BBDAA3B8E; Tue, 14 Sep 2021 09:11:36 +0000 (UTC) From: Jiri Slaby To: gregkh@linuxfoundation.org Cc: linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org, Jiri Slaby , Wolfgang Grandegger , Marc Kleine-Budde , "David S. Miller" , Jakub Kicinski , Andreas Koensgen , Paul Mackerras Subject: [PATCH 05/16] tty: remove file from tty_mode_ioctl Date: Tue, 14 Sep 2021 11:11:23 +0200 Message-Id: <20210914091134.17426-5-jslaby@suse.cz> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210914091134.17426-1-jslaby@suse.cz> References: <20210914091134.17426-1-jslaby@suse.cz> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. Signed-off-by: Jiri Slaby Cc: Wolfgang Grandegger Cc: Marc Kleine-Budde Cc: "David S. Miller" Cc: Jakub Kicinski Cc: Andreas Koensgen Cc: Paul Mackerras --- drivers/net/can/slcan.c | 2 +- drivers/net/hamradio/6pack.c | 2 +- drivers/net/ppp/ppp_async.c | 2 +- drivers/net/ppp/ppp_synctty.c | 2 +- drivers/net/slip/slip.c | 2 +- drivers/tty/tty_ioctl.c | 8 ++------ include/linux/tty.h | 3 +-- 7 files changed, 8 insertions(+), 13 deletions(-) diff --git a/drivers/net/can/slcan.c b/drivers/net/can/slcan.c index 012da4b8abe0..9a4ebda30510 100644 --- a/drivers/net/can/slcan.c +++ b/drivers/net/can/slcan.c @@ -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); } } diff --git a/drivers/net/hamradio/6pack.c b/drivers/net/hamradio/6pack.c index 8fe8887d506a..05404f7a3204 100644 --- a/drivers/net/hamradio/6pack.c +++ b/drivers/net/hamradio/6pack.c @@ -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); diff --git a/drivers/net/ppp/ppp_async.c b/drivers/net/ppp/ppp_async.c index 78ec1bcebc4f..6492523fc234 100644 --- a/drivers/net/ppp/ppp_async.c +++ b/drivers/net/ppp/ppp_async.c @@ -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); diff --git a/drivers/net/ppp/ppp_synctty.c b/drivers/net/ppp/ppp_synctty.c index c249db7c466a..ebbfea0e1140 100644 --- a/drivers/net/ppp/ppp_synctty.c +++ b/drivers/net/ppp/ppp_synctty.c @@ -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; } diff --git a/drivers/net/slip/slip.c b/drivers/net/slip/slip.c index 8be9d0c351b5..9f3b4c1aa5ce 100644 --- a/drivers/net/slip/slip.c +++ b/drivers/net/slip/slip.c @@ -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); } } diff --git a/drivers/tty/tty_ioctl.c b/drivers/tty/tty_ioctl.c index 507a25d692bb..99a29d72d294 100644 --- a/drivers/tty/tty_ioctl.c +++ b/drivers/tty/tty_ioctl.c @@ -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); diff --git a/include/linux/tty.h b/include/linux/tty.h index 15453b0c4081..5e73f577c2b4 100644 --- a/include/linux/tty.h +++ b/include/linux/tty.h @@ -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); -- 2.33.0