Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp1653684pxa; Thu, 20 Aug 2020 17:30:01 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyRoDn+Y94QIAAitHnyC9MtqPklaGbdY1AF5eLXrbHdIxXK44oAAa+I4MCFAPsdIc1sB4hn X-Received: by 2002:a05:6402:2206:: with SMTP id cq6mr320361edb.349.1597969801026; Thu, 20 Aug 2020 17:30:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597969801; cv=none; d=google.com; s=arc-20160816; b=Gdu2VO8rt8B4oXjwyHsafGtCrtevZrZkv2EB2QMYTJ52RjVvk5ljhr5KFEmWVlURUp E9dnwLBcTnpN5ZaVRPsby8AleLJkIsuL3wNtTwANOnjCwaRpYBZJ5AbCdrJ9FmSaqlGh sydAu4eCvqKy1yc/XIGV0VXMT6LwunFXlw2dH18eTRZ47r3QU9HxQjF9xV5in1sZUie4 sw5fKB9tpqgJEM4vT67SlFhlcf0V6cqUYPW5ZvdCGqfKyh7YYAz0t08bFUujX69y3cXk GDU+cAlmZMWnm/rg7eyb5wfiqvHf6KrHGlf/B+oOPxqVjdiU2/NoB92dS8lrcEXnHndQ cE9g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=LWvgozH5vCWQa6DI9mHHCsXlRgKTLkBwgr56N3JBteM=; b=Xex2U+lZo5SFbsl/Cbr+U4KgMKpqwVk50amBW/yB0oBop7udQfCvDH3bWj9cGPdT9D Ctqde9FBpLRqEW+FY5thFeIXqGn3T3jDOVOG1q4UBCT16t2ePw9q5ZyQuNveP+aEUAYR c4O6ETrCbP5n6R1UkLhyIp1K/sJ5A8MzJRIsWMs6Y/0Lu2v3t6lUS72XEMYL9+shf/9t AE5qaU1hmIEPc6P8sQajTfGaV+XryyPE9bWGV84uJJnmu+swOwBrVZyvTD7CsLcPofSR u2yGNJB9sUcn7EL2+P9Ee4zCmId5pKmZT/TtUYSkjgqvLnJZu0IprZMloGrFLQMDjpre g57w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=lBI80qt1; 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=ibm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id v17si45403ejd.324.2020.08.20.17.29.37; Thu, 20 Aug 2020 17:30:01 -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=@ibm.com header.s=pp1 header.b=lBI80qt1; 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=ibm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726806AbgHUA1A (ORCPT + 99 others); Thu, 20 Aug 2020 20:27:00 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:29882 "EHLO mx0b-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725834AbgHUA07 (ORCPT ); Thu, 20 Aug 2020 20:26:59 -0400 Received: from pps.filterd (m0098417.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 07KNWpEw114447; Thu, 20 Aug 2020 19:46:48 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : mime-version : content-transfer-encoding; s=pp1; bh=LWvgozH5vCWQa6DI9mHHCsXlRgKTLkBwgr56N3JBteM=; b=lBI80qt1adQ1aj3+OHi0Bfuwb49yLnIKeghJkY4Ank1eu0SO3+wh5tqg6Jvaw6uSErsL Jve/D8qm+Ffyg8/iYTMv7/5+9cqvJtaRASwovGGhukf6dEhqDkc6r3+ygBtfugdHlV9O W+cZo97lOH0JiG2oCZ3xRWeIYcam5N5vHU6Z4AYsK9lFl1Q1reIsLxLBcLGEiwju3pb3 mYGEokgkQpxVNyNDrc55D5jj12XqLObxu25PgwQ8wa3pjz9Lo/JW1n4IVgXvHrkfxDdP ejiEspS8ZtasluAPQKpfOjiUjoPkeoamxOgQJh79FX80S98RERpKPmXroQZXOzQbKai0 tg== Received: from ppma01wdc.us.ibm.com (fd.55.37a9.ip4.static.sl-reverse.com [169.55.85.253]) by mx0a-001b2d01.pphosted.com with ESMTP id 3314mx5mpp-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 20 Aug 2020 19:46:48 -0400 Received: from pps.filterd (ppma01wdc.us.ibm.com [127.0.0.1]) by ppma01wdc.us.ibm.com (8.16.0.42/8.16.0.42) with SMTP id 07KNiq1i020052; Thu, 20 Aug 2020 23:46:47 GMT Received: from b01cxnp23034.gho.pok.ibm.com (b01cxnp23034.gho.pok.ibm.com [9.57.198.29]) by ppma01wdc.us.ibm.com with ESMTP id 3304tkyvff-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 20 Aug 2020 23:46:47 +0000 Received: from b01ledav005.gho.pok.ibm.com (b01ledav005.gho.pok.ibm.com [9.57.199.110]) by b01cxnp23034.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 07KNkkEA53215654 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 20 Aug 2020 23:46:47 GMT Received: from b01ledav005.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id DF71FAE05C; Thu, 20 Aug 2020 23:46:46 +0000 (GMT) Received: from b01ledav005.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 6FE70AE05F; Thu, 20 Aug 2020 23:46:46 +0000 (GMT) Received: from localhost.localdomain (unknown [9.40.195.188]) by b01ledav005.gho.pok.ibm.com (Postfix) with ESMTP; Thu, 20 Aug 2020 23:46:46 +0000 (GMT) From: Tyrel Datwyler To: gregkh@linuxfoundation.org Cc: Tyrel Datwyler , Jiri Slaby , Jason Yan , Joe Perches , linuxppc-dev@lists.ozlabs.org (open list:HYPERVISOR VIRTUAL CONSOLE DRIVER), linux-kernel@vger.kernel.org (open list) Subject: [PATCH] tty: hvcs: Don't NULL tty->driver_data until hvcs_cleanup() Date: Thu, 20 Aug 2020 18:46:38 -0500 Message-Id: <20200820234643.70412-1-tyreld@linux.ibm.com> X-Mailer: git-send-email 2.27.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-TM-AS-GCONF: 00 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.235,18.0.687 definitions=2020-08-20_07:2020-08-19,2020-08-20 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 priorityscore=1501 adultscore=0 impostorscore=0 phishscore=0 bulkscore=0 malwarescore=0 mlxscore=0 suspectscore=3 mlxlogscore=963 clxscore=1011 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2006250000 definitions=main-2008200193 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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(). Signed-off-by: Tyrel Datwyler --- 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 55105ac38f89..509d1042825a 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.27.0