Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp1976864pxb; Fri, 5 Mar 2021 04:36:12 -0800 (PST) X-Google-Smtp-Source: ABdhPJxPekcgVAiCFvnGfYODpD/r6yGhJXBpI+XQn6hW4zlsjLX3JzV8jd12oRnrYJ6/7fpRdIK1 X-Received: by 2002:a17:906:706:: with SMTP id y6mr2045648ejb.274.1614947772213; Fri, 05 Mar 2021 04:36:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614947772; cv=none; d=google.com; s=arc-20160816; b=t3GcCxHKfphO00vK9uBJVPlTqV+UOD59A1MuTyVH0r4qvp8PoH5MZNlkhQh8ioJWYa HAFtgsTcN9w+K2HMSLZ5dh0zvSiMgmvjTxVUFW7m+xhZ7qZBnYLqx9Pmc/dwEFi+0tEy Bqu3ZErpO+q9lEw6CV0MlDfltesGtGuoe65BHvi0KRTMEbr3Wf1LH8LdviU9JTqn0DmK V8cW5XXi6h++dqm7fgolJIl6+PrrnLZtDy7JktBY/Ml1JtdDYJH5ktnHOcBCqoa281Q9 Fom/aSmdIiG0+n16sOHsUWaSvj46rZsdFmImkOcndPwDpGik4W3Hu+R/GuhlvgyoVR8A 4WeA== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=GFFDQVET63Mh5WcjPNK1azlnvGDRHJED1zNr1JTkuRg=; b=V+BGItIgsGap1MimtyrGSNm2yKe1i55ZkPFyGcvp1JlJhQks0QYP+dgTXhw4anUaW0 HTBsOyQmzyXO9fA7tKxJXdHZoGAz522F9Aube7mtOraYvreXAXSf1T6z7gaRuAvFS+P8 BR24fRrohLWuJReA3vrIF1cG0S9WPZXZ5CUn4XdhcE7WNtCy1wOIhbYTPZ1vIdyXgtOw 5wnxt+YmnIqHilFboRjZ6XIAoSDQYS4rncG8gLGsp/xMATdmEeXyDsVKcyznhjD7Hn83 AMTeSnCq/DN1jRR/BD3O8BJicQS+fu4Yv3vpZZ1dNxTcz1NuikeVmc9Zk7byMs40qF/b Dfkw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Q2fipudG; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id a4si1261610ejv.296.2021.03.05.04.35.49; Fri, 05 Mar 2021 04:36:12 -0800 (PST) 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=@linuxfoundation.org header.s=korg header.b=Q2fipudG; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231284AbhCEMcy (ORCPT + 99 others); Fri, 5 Mar 2021 07:32:54 -0500 Received: from mail.kernel.org ([198.145.29.99]:42384 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232692AbhCEMcM (ORCPT ); Fri, 5 Mar 2021 07:32:12 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 1B95565004; Fri, 5 Mar 2021 12:32:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1614947531; bh=ZL/ISVxB/URfSiYGOh/8n7lxXaouo+uBF14P0qxpBoE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Q2fipudGPlJ4g6J5KJMyAqocQ9OfbCbiPxZW9DSXolipE7fUsn0K9v9VdTWGAOgNe kKdCIVZXNWoP4N5B4RBw6Y37eKMcyVFTuHftNAudxZckOr/XIrXN1IHCejvSo29/KQ qNrsVAgDgbfccsLNSlyofzIJVzQ3+lE546u30naE= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Linus Torvalds Subject: [PATCH 5.10 096/102] tty: clean up legacy leftovers from n_tty line discipline Date: Fri, 5 Mar 2021 13:21:55 +0100 Message-Id: <20210305120908.002060146@linuxfoundation.org> X-Mailer: git-send-email 2.30.1 In-Reply-To: <20210305120903.276489876@linuxfoundation.org> References: <20210305120903.276489876@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Linus Torvalds commit 64a69892afadd6fffaeadc65427bb7601161139d upstream. Back when the line disciplines did their own direct user accesses, they had to deal with the data copy possibly failing in the middle. Now that the user copy is done by the tty_io.c code, that failure case no longer exists. Remove the left-over error handling code that cannot trigger. Signed-off-by: Linus Torvalds Signed-off-by: Greg Kroah-Hartman --- drivers/tty/n_tty.c | 29 +++++++++-------------------- 1 file changed, 9 insertions(+), 20 deletions(-) --- a/drivers/tty/n_tty.c +++ b/drivers/tty/n_tty.c @@ -1955,19 +1955,17 @@ static inline int input_available_p(stru * read_tail published */ -static int copy_from_read_buf(struct tty_struct *tty, +static void copy_from_read_buf(struct tty_struct *tty, unsigned char **kbp, size_t *nr) { struct n_tty_data *ldata = tty->disc_data; - int retval; size_t n; bool is_eof; size_t head = smp_load_acquire(&ldata->commit_head); size_t tail = ldata->read_tail & (N_TTY_BUF_SIZE - 1); - retval = 0; n = min(head - ldata->read_tail, N_TTY_BUF_SIZE - tail); n = min(*nr, n); if (n) { @@ -1984,7 +1982,6 @@ static int copy_from_read_buf(struct tty *kbp += n; *nr -= n; } - return retval; } /** @@ -2010,9 +2007,9 @@ static int copy_from_read_buf(struct tty * read_tail published */ -static int canon_copy_from_read_buf(struct tty_struct *tty, - unsigned char **kbp, - size_t *nr) +static void canon_copy_from_read_buf(struct tty_struct *tty, + unsigned char **kbp, + size_t *nr) { struct n_tty_data *ldata = tty->disc_data; size_t n, size, more, c; @@ -2022,7 +2019,7 @@ static int canon_copy_from_read_buf(stru /* N.B. avoid overrun if nr == 0 */ if (!*nr) - return 0; + return; n = min(*nr + 1, smp_load_acquire(&ldata->canon_head) - ldata->read_tail); @@ -2069,7 +2066,6 @@ static int canon_copy_from_read_buf(stru ldata->push = 0; tty_audit_push(); } - return 0; } /** @@ -2219,24 +2215,17 @@ static ssize_t n_tty_read(struct tty_str } if (ldata->icanon && !L_EXTPROC(tty)) { - retval = canon_copy_from_read_buf(tty, &kb, &nr); - if (retval) - break; + canon_copy_from_read_buf(tty, &kb, &nr); } else { - int uncopied; - /* Deal with packet mode. */ if (packet && kb == kbuf) { *kb++ = TIOCPKT_DATA; nr--; } - uncopied = copy_from_read_buf(tty, &kb, &nr); - uncopied += copy_from_read_buf(tty, &kb, &nr); - if (uncopied) { - retval = -EFAULT; - break; - } + /* See comment above copy_from_read_buf() why twice */ + copy_from_read_buf(tty, &kb, &nr); + copy_from_read_buf(tty, &kb, &nr); } n_tty_check_unthrottle(tty);