Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp9089320pxu; Mon, 28 Dec 2020 06:22:25 -0800 (PST) X-Google-Smtp-Source: ABdhPJzM3JJ4S1RjipXbfZR/nZU5USPRSDVkj/NTi4441a0lQDrvOWPO8VEbz9ubL4YXI/IbIFJ6 X-Received: by 2002:a17:906:1a5a:: with SMTP id j26mr42063275ejf.225.1609165344815; Mon, 28 Dec 2020 06:22:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1609165344; cv=none; d=google.com; s=arc-20160816; b=wg0ixzjAkAtFSAVRTwKaj+VUHQGKg5/WgJTRfwDpNjj/5mr3z9vwwCoDnscvSu4U1s Hz7uQ6zHtQQXy9AS7chfNuA9bI0i8ggvIQweiJr1IGdS3SJur6Pv64cf1HZLjZ1KTuqc 50hO614e65JfbawdGqdRxQhf48xmFXrmpntdnXeafkJRgZZvk+70XKNKlvjf8eeRc9AU 4lEd9A8arU4h4McSF8RMP1ucSmVRzG0PSWYI4qoqE1w5mwFt2yVNBmBseTufto5to93j SAJX4vGhO0ilx75r4vdRT3DGgd0r+97tdFq0JPXp/9XhOJpxDe9azg4JYESzwCJGWSlJ 9+Ng== 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=DtaZsjnHLMIr2qxBqMMBkK1H3fmlMymqojabqh+Z7Uo=; b=jSlOZaYRkVasAf1zxsMBMRVIbGjv8rid3I5vaw5BRCiL3VrbKQU1ZmU/QEQ41qDzfo KYmQcY8ftu0xUFOcuiSJ/D/MoUck+AISbSWjfALlQARtlOMP932prroGT0uh9dmvBN8O CQNZme5pyCS4mUsthOXE8XR4EjY+JXTcPjH9DBeAMXCT1DMSSo26dgadInk+LxzNdBKd EhdxFAL1pw7ToVpWiHI18GUfbBqFsf6XbcHegATA/3sigi8051ioc3MyFxSfpocIyX/X PSM8tOrqi13rD6N4+mNbuGgsw/CFPome0aKZ2Pt/KzIpi272+akiw1AUSJ1GfdKjUR/7 p7oA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Jf79SvEB; 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 i8si7753208edu.515.2020.12.28.06.22.01; Mon, 28 Dec 2020 06:22:24 -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=Jf79SvEB; 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 S2436599AbgL1OUK (ORCPT + 99 others); Mon, 28 Dec 2020 09:20:10 -0500 Received: from mail.kernel.org ([198.145.29.99]:55430 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2436589AbgL1OUH (ORCPT ); Mon, 28 Dec 2020 09:20:07 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 418D022573; Mon, 28 Dec 2020 14:19:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1609165166; bh=nVCVeaYmCZ31IeiiiRWPTdvvzAVNd5cTuQmGpIDznt0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Jf79SvEBKeK9mcE/aL0efbs0jkZRKTA8v4dgF2CWakB4HU//+cQXcpGSRAPaFHGOH NdQzXTR2QFiSzhKl1oVfW+/+5usxve4q2KnrlOdC4cb2S5Ft7DT4WKqkdk5zkdeDBO 2vf2Sj7vkxzFCAbc270jvWC135aGKVEcM+Gl9lhA= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Anton Ivanov , Richard Weinberger , Sasha Levin Subject: [PATCH 5.10 435/717] um: tty: Fix handling of close in tty lines Date: Mon, 28 Dec 2020 13:47:13 +0100 Message-Id: <20201228125041.812890471@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201228125020.963311703@linuxfoundation.org> References: <20201228125020.963311703@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: Anton Ivanov [ Upstream commit 9b1c0c0e25dcccafd30e7d4c150c249cc65550eb ] Fix a logical error in tty reading. We get 0 and errno == EAGAIN on the first attempt to read from a closed file descriptor. Compared to that a true EAGAIN is EAGAIN and -1. If we check errno for EAGAIN first, before checking the return value we miss the fact that the descriptor is closed. This bug is as old as the driver. It was not showing up with the original POLL based IRQ controller, because it was producing multiple events. Switching to EPOLL unmasked it. Fixes: ff6a17989c08 ("Epoll based IRQ controller") Signed-off-by: Anton Ivanov Signed-off-by: Richard Weinberger Signed-off-by: Sasha Levin --- arch/um/drivers/chan_user.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/um/drivers/chan_user.c b/arch/um/drivers/chan_user.c index 4d80526a4236e..d8845d4aac6a7 100644 --- a/arch/um/drivers/chan_user.c +++ b/arch/um/drivers/chan_user.c @@ -26,10 +26,10 @@ int generic_read(int fd, char *c_out, void *unused) n = read(fd, c_out, sizeof(*c_out)); if (n > 0) return n; - else if (errno == EAGAIN) - return 0; else if (n == 0) return -EIO; + else if (errno == EAGAIN) + return 0; return -errno; } -- 2.27.0