Received: by 2002:a05:6a10:9e8c:0:0:0:0 with SMTP id y12csp374650pxx; Wed, 28 Oct 2020 07:00:53 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyK+y7MHNEnz+ZEsP7ZMmeFCX5xUPcvf46lOmisDmII68lD9Jq39Z/prjU1pqTjJ4uEEYWS X-Received: by 2002:a02:c6ba:: with SMTP id o26mr7020413jan.104.1603893653351; Wed, 28 Oct 2020 07:00:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603893652; cv=none; d=google.com; s=arc-20160816; b=nHsiYYCC26HqIyagUOYlZOnUbMWUinthsjFTGeAEnmQQa8DnS3tGAZDcWVbi6EM13T x30AC34J0aTHF3ubc+RwHFDVHENqjbEIv2Rkv255wSBzNCOk4rNhwlP7r24naoockePD uSUjZRfao4nOXn82f0IV1SHUl9hEoaVMwrmuD9PaVascBph+DbA92GJSKA/T0okQphDv h8/Be43LK1TdaY6qht1IVABbi94rshLPYvIROxm8SY4s3Jt09IrsPonqV/0gWo5+WlG6 TxJH2gS0HoTyOmIbhWaB9ey4Hcwkfj2c3agU/GodfHTq2W2eeZpWOZRRuKuC8JknAKGl Fgyg== 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=3zDbX0q/FSnbxRJ283ZUZXimFfa1lmAx0wGS8Kc+vZk=; b=iECFExALmGelVBNRHjAnMdASRu+IzIiE9XHW88xgICtTMqHoxd952/zIERcI0Z1SSH rD9eIZgKQPo9e5CPibrc+0d3rwgBdpEGQca94Z+diCJXai71rIaeTc+CK/6rTylp6eDz C6O+VAMMkC4Cjzu9OqtKH3l1JnZvJdPP+8zaVlzVVM1y6gUfqqUXdr9V3ZqhnxkCu9Zl bAPKBuBPSRir3ojgyzC0my+ibyjZo+HvHwu/zr672e263dFkDMll532e+AbZJSNsvjRE kow5bXvgkgFy/TJ/hSiiwrrKH3bGWWbOZAFJW48ykzDxZHwjr+BGQHiSlfOG7R++ULHe T58Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=OjPU1ocW; 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 p90si2749641edd.284.2020.10.28.07.00.30; Wed, 28 Oct 2020 07:00:52 -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=OjPU1ocW; 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 S1803630AbgJ0PxM (ORCPT + 99 others); Tue, 27 Oct 2020 11:53:12 -0400 Received: from mail.kernel.org ([198.145.29.99]:44324 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1798505AbgJ0P2Y (ORCPT ); Tue, 27 Oct 2020 11:28:24 -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 CA55A2064B; Tue, 27 Oct 2020 15:28:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1603812503; bh=W+K7W4+QGo782brgjmLPUIo3oVKY6jD0sJmTUqB5PVM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=OjPU1ocW/MmzP3Pp6TYC7dq8iC1+8xemBVojOW1fCJHdzy/zFrUPuGRmxLqHtjzmw FDieoLstfad4bdVk+mY79g/wKuyCob4WYAeTjp3FHExSciek6c2+96PrleD+wToaQF LfLqgGbTx8p5B5+LAAwLgNfeedRpwGhxM1hEXauc= 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.9 232/757] tty: hvcs: Dont NULL tty->driver_data until hvcs_cleanup() Date: Tue, 27 Oct 2020 14:48:02 +0100 Message-Id: <20201027135501.488886858@linuxfoundation.org> X-Mailer: git-send-email 2.29.1 In-Reply-To: <20201027135450.497324313@linuxfoundation.org> References: <20201027135450.497324313@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 55105ac38f89b..509d1042825a1 100644 --- a/drivers/tty/hvc/hvcs.c +++ b/drivers/tty/hvc/hvcs.c @@ -1216,13 +1216,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) { @@ -1237,6 +1230,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