Received: by 2002:a05:6a10:9e8c:0:0:0:0 with SMTP id y12csp529315pxx; Wed, 28 Oct 2020 10:22:24 -0700 (PDT) X-Google-Smtp-Source: ABdhPJykr8hT+FYFD4HZ5BQTeqHvXDOzit7k+gEv2LzRvnGoUtDnheTvQ7hTIQkh9O21vytSN5Bj X-Received: by 2002:a05:6402:207c:: with SMTP id bd28mr8603994edb.316.1603905743995; Wed, 28 Oct 2020 10:22:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603905743; cv=none; d=google.com; s=arc-20160816; b=GP56/Yfm7D3lcSHqmHoJQtlXfPYjIDM8fcQZL3xTpT7wvHbYXuFqczOt3xWZ/qsQaI UQgQArlK7RAWdkyc9hdCypWQZe3EDJMHJqrR6IYmQnJldORWnZ4oSDu4wBbCyH+jPrdz RSXTUJJG/baDrfRnByoNb6mIB2vTGrW4gasfNLMOTts7FvExMKpeqtSkdJw+0FYUwCCO KRs5Lb8Jq8Wnn1BSPM4E+3rZ8bQSrm89tnzQ4+A+r4Wx3hY+36oc7lHtAcRNrCRicjvM xFfcVxRJhcVSelAiLfVtHWFAzkylyvqxVFwF2XIfbXgQ/g4a/rX26obuKi7D7YQadGKV 7PxA== 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=Cf0CAMDgVHDdpw3SkV36ZXw9nWOTepQxrb+kQuE+RY8=; b=VBfwtwy7sBAXDvk0gsvWiicMVmh4FzpPQENQZf7txFzIYh0MlQMIYiY8/FDNObCvsL H1Qis1eIY6MCOh0/bUinMuDP34iz1eYN+uiownXQhbL5ja8wKiSAXPV2ZMxxocFtpt7n deDp89Iclpbkgg8qSWYdy8LE5kkEaYaAQTMpd2rFQhP/uo4YsBaoSwYDFrBFybF7cCpA YrMFn36I3FCJm1aCdL5hKBEjC/To28azcv7SYuAfKKOCc1flYDebOY8BNYCV/D7Bx4nr jKyRrHOhvHD52+rvRnzsHZKsGC+0rOHKa/tCoyG1rwCWRj0yLIlf9pw842ezjHGipUzv GTqQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="o/YcTbGK"; 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=fail (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 x19si30189edq.122.2020.10.28.10.22.01; Wed, 28 Oct 2020 10:22:23 -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=@kernel.org header.s=default header.b="o/YcTbGK"; 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=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1820847AbgJ0RjP (ORCPT + 99 others); Tue, 27 Oct 2020 13:39:15 -0400 Received: from mail.kernel.org ([198.145.29.99]:32948 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2898420AbgJ0OeL (ORCPT ); Tue, 27 Oct 2020 10:34:11 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 3283320709; Tue, 27 Oct 2020 14:34:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1603809250; bh=oqFJHYCHJDAmonOunTiIlV9+jTO/MRQsZuPFjEx01d0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=o/YcTbGKqtDdCEfcWcsF9h8QpcxiPtJeYh76diZ3v2D3AUCkIxwHQaTdDILTC+tp4 RGH/ogWDP1ctK3NhsLdGyEaHs2FmJBtlX5mU+haZxncRsT8elBR1dzjTscn7dgzvSv 7EwIynwV+GnHi80DZz0Ar58MlvNFcqVu+hwIIh44= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Tyrel Datwyler , Sasha Levin Subject: [PATCH 5.4 130/408] tty: hvcs: Dont NULL tty->driver_data until hvcs_cleanup() Date: Tue, 27 Oct 2020 14:51:08 +0100 Message-Id: <20201027135501.120893326@linuxfoundation.org> X-Mailer: git-send-email 2.29.1 In-Reply-To: <20201027135455.027547757@linuxfoundation.org> References: <20201027135455.027547757@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: Tyrel Datwyler [ Upstream commit 63ffcbdad738e3d1c857027789a2273df3337624 ] The code currently NULLs tty->driver_data in hvcs_close() with the intent of informing the next call to hvcs_open() that device needs to be reconfigured. However, when hvcs_cleanup() is called we copy hvcsd from tty->driver_data which was previoulsy NULLed by hvcs_close() and our call to tty_port_put(&hvcsd->port) doesn't actually do anything since &hvcsd->port ends up translating to NULL by chance. This has the side effect that when hvcs_remove() is called we have one too many port references preventing hvcs_destuct_port() from ever being called. This also prevents us from reusing the /dev/hvcsX node in a future hvcs_probe() and we can eventually run out of /dev/hvcsX devices. Fix this by waiting to NULL tty->driver_data in hvcs_cleanup(). Fixes: 27bf7c43a19c ("TTY: hvcs, add tty install") Signed-off-by: Tyrel Datwyler Link: https://lore.kernel.org/r/20200820234643.70412-1-tyreld@linux.ibm.com Signed-off-by: Greg Kroah-Hartman Signed-off-by: Sasha Levin --- drivers/tty/hvc/hvcs.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/drivers/tty/hvc/hvcs.c b/drivers/tty/hvc/hvcs.c index ee0604cd9c6b2..0c498b20d8cb5 100644 --- a/drivers/tty/hvc/hvcs.c +++ b/drivers/tty/hvc/hvcs.c @@ -1218,13 +1218,6 @@ static void hvcs_close(struct tty_struct *tty, struct file *filp) tty_wait_until_sent(tty, HVCS_CLOSE_WAIT); - /* - * This line is important because it tells hvcs_open that this - * device needs to be re-configured the next time hvcs_open is - * called. - */ - tty->driver_data = NULL; - free_irq(irq, hvcsd); return; } else if (hvcsd->port.count < 0) { @@ -1239,6 +1232,13 @@ static void hvcs_cleanup(struct tty_struct * tty) { struct hvcs_struct *hvcsd = tty->driver_data; + /* + * This line is important because it tells hvcs_open that this + * device needs to be re-configured the next time hvcs_open is + * called. + */ + tty->driver_data = NULL; + tty_port_put(&hvcsd->port); } -- 2.25.1