Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp3598911imw; Thu, 7 Jul 2022 04:40:13 -0700 (PDT) X-Google-Smtp-Source: AGRyM1vN33s0OZ72f3Wzqu3OSUb9R1qYWKWz+mKrGCnp8ulzaYxIP1N6mWD5X1b/TsEeJFaZXMNV X-Received: by 2002:a17:907:628a:b0:6fe:526c:ebc with SMTP id nd10-20020a170907628a00b006fe526c0ebcmr42185856ejc.531.1657194012903; Thu, 07 Jul 2022 04:40:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657194012; cv=none; d=google.com; s=arc-20160816; b=LarKtUGppFq6cwMKnDxrdOP0E5qOVyfqSaVG0rx2QkdTUxuQ4qmoR8muSByxstl5SC FaW9LpwFXzbZnN4NjKSF9ixmpSMy7KENsrtIy4FYwBUN+81+O5E5++Q6cR4t4z2XqH49 VeI6lDBieTWe7UCMNJJf8DkxXq/FTlKPVJVsE3/M/a+jvbLLF/kT6EjkkBE++OHbXc86 IM5aF0/TRD1EA4uk/q8nc3nyW3gFGtQmT4HHsomP0f615TQLBSsYrH/gIGWDvFgbnupg G+57GFOAasu6PnaeKna/tUHQV9g5WhTj1XfFibjUy0NH40Itd1pzZEDoh60IbyifCe7d bR5Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:feedback-id:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=dmsPVO/ob5l26R3xUoVk7IKDPFVjQUBwffjZsB2FjME=; b=Hlfp9FrRgoGopiwKc9wajNY1rZqQfUlHfyzWKEniqOQ09RU0qysIAuFrJc68TlytAr bW4klHVRLn//Sfw1JRYBkIJosY4rxsZiN76YYilhXntldNmpO7KH+0RiNJrg6gPdEPJr 2kBl+6ZWSxlZk/ytsB98dpKN99R/t/FxEHa3uyr4OmgTzqM7dPQn51tIC91gopDANRQz FXgnESTiJ5RldyDv3awBkJk7YwgGfxENzzAGKqjtafC1BeVQSrZ2eJwqpeuVOc0T8cpT RPUYiYwgPcDk3XCmFxS9hPn0xYWjhbDSglNDNxG7fzj6FPn0S9RnYfYJ6N4vesHojfE8 wYUQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@siemens.com header.s=fm1 header.b=fuObogHG; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=siemens.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id sa5-20020a1709076d0500b00726efe5b919si1414802ejc.806.2022.07.07.04.39.45; Thu, 07 Jul 2022 04:40:12 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@siemens.com header.s=fm1 header.b=fuObogHG; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=siemens.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235426AbiGGLeD (ORCPT + 99 others); Thu, 7 Jul 2022 07:34:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42646 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235385AbiGGLdy (ORCPT ); Thu, 7 Jul 2022 07:33:54 -0400 Received: from mta-64-227.siemens.flowmailer.net (mta-64-227.siemens.flowmailer.net [185.136.64.227]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CE54A30564 for ; Thu, 7 Jul 2022 04:33:52 -0700 (PDT) Received: by mta-64-227.siemens.flowmailer.net with ESMTPSA id 20220707113350cce0cc7fefb8b37d1a for ; Thu, 07 Jul 2022 13:33:51 +0200 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; s=fm1; d=siemens.com; i=daniel.starke@siemens.com; h=Date:From:Subject:To:Message-ID:MIME-Version:Content-Type:Content-Transfer-Encoding:Cc:References:In-Reply-To; bh=dmsPVO/ob5l26R3xUoVk7IKDPFVjQUBwffjZsB2FjME=; b=fuObogHGxaCf7YeIywwKa5Xb2x6mvl0/hoF9lr59apW4GkCU+2bVT63otI8wa2OumikRrI zgNJqEPWYJSghpEz4UjJZ0dY2Y4HEe3XwwQOjDwzUgiAZL66ybOUyuSZguSPwwO0G4AczqyE 7gFuuqdAlJPUCvtv8sOobgf2hYafQ=; From: "D. Starke" To: linux-serial@vger.kernel.org, gregkh@linuxfoundation.org, jirislaby@kernel.org Cc: linux-kernel@vger.kernel.org, Daniel Starke Subject: [PATCH v2 4/4] tty: n_gsm: fix missing corner cases in gsmld_poll() Date: Thu, 7 Jul 2022 13:32:23 +0200 Message-Id: <20220707113223.3685-4-daniel.starke@siemens.com> In-Reply-To: <20220707113223.3685-1-daniel.starke@siemens.com> References: <20220707113223.3685-1-daniel.starke@siemens.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Flowmailer-Platform: Siemens Feedback-ID: 519:519-314044:519-21489:flowmailer X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Daniel Starke gsmld_poll() currently fails to handle the following corner cases correctly: - remote party closed the associated tty Add the missing checks and map those to EPOLLHUP. Reorder the checks to group them by their reaction. Fixes: e1eaea46bb40 ("tty: n_gsm line discipline") Signed-off-by: Daniel Starke --- drivers/tty/n_gsm.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) Check for valid pointer in tty->disc_data has been removed compared to v1. Link: https://lore.kernel.org/all/17759c4b-5858-12bb-4beb-c4a1d58c89ae@kernel.org/ diff --git a/drivers/tty/n_gsm.c b/drivers/tty/n_gsm.c index 51447ccccbab..caa5c14ed57f 100644 --- a/drivers/tty/n_gsm.c +++ b/drivers/tty/n_gsm.c @@ -3053,12 +3053,15 @@ static __poll_t gsmld_poll(struct tty_struct *tty, struct file *file, poll_wait(file, &tty->read_wait, wait); poll_wait(file, &tty->write_wait, wait); + + if (gsm->dead) + mask |= EPOLLHUP; if (tty_hung_up_p(file)) mask |= EPOLLHUP; + if (test_bit(TTY_OTHER_CLOSED, &tty->flags)) + mask |= EPOLLHUP; if (!tty_is_writelocked(tty) && tty_write_room(tty) > 0) mask |= EPOLLOUT | EPOLLWRNORM; - if (gsm->dead) - mask |= EPOLLHUP; return mask; } -- 2.34.1