From patchwork Fri Feb 3 15:58:00 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Brian King X-Patchwork-Id: 650580 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 58044C61DA4 for ; Fri, 3 Feb 2023 15:58:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232611AbjBCP6V (ORCPT ); Fri, 3 Feb 2023 10:58:21 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60796 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233356AbjBCP6S (ORCPT ); Fri, 3 Feb 2023 10:58:18 -0500 Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6E7A317161 for ; Fri, 3 Feb 2023 07:58:16 -0800 (PST) Received: from pps.filterd (m0187473.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 313FgTYo011533; Fri, 3 Feb 2023 15:58:12 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=pp1; bh=djD0RZ9OL8E4ra+yAXgzKX6kFBYyu/8WLCVWpHfJIqY=; b=TSoHceQa6GxjBZICX1mr8QRCFcqIPYv9fUpXtSmfel/6bH/ijcTTwTjDuDmUh5bQZGEn 07e0YCeY8/1qw83Yn+h2Ebigj46EpiC6+QryIHn32e1ClIELetBirP+PXw7PYUTw8WH2 +0Drms6qq/NtXCj9wIw0+Alzd6MzolH7DwjDXbgMdj+0R3jJiwKnuZoJPzPGELIps8TC yjOGL+TZKJP8YIjKGxao14r4OCSMnKggOAcScDt7GJZIux3b+mHtS1nsS2csq2+wy01A /LgQRvWsnbfjA/IH/svmc5IiAPmXQh/QCTRHYpYLHiuZNux0XvxuIKHt+iiIgud3sBdf 9g== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3nh554gbxr-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 03 Feb 2023 15:58:12 +0000 Received: from m0187473.ppops.net (m0187473.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 313FguZO012999; Fri, 3 Feb 2023 15:58:12 GMT Received: from ppma02wdc.us.ibm.com (aa.5b.37a9.ip4.static.sl-reverse.com [169.55.91.170]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3nh554gbxc-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 03 Feb 2023 15:58:12 +0000 Received: from pps.filterd (ppma02wdc.us.ibm.com [127.0.0.1]) by ppma02wdc.us.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 313FpV9I004994; Fri, 3 Feb 2023 15:58:10 GMT Received: from smtprelay02.wdc07v.mail.ibm.com ([9.208.129.120]) by ppma02wdc.us.ibm.com (PPS) with ESMTPS id 3ncvv29hps-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 03 Feb 2023 15:58:10 +0000 Received: from smtpav03.dal12v.mail.ibm.com (smtpav03.dal12v.mail.ibm.com [10.241.53.102]) by smtprelay02.wdc07v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 313Fw9Jl43975094 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 3 Feb 2023 15:58:09 GMT Received: from smtpav03.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 5882358061; Fri, 3 Feb 2023 15:58:09 +0000 (GMT) Received: from smtpav03.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id D075658063; Fri, 3 Feb 2023 15:58:08 +0000 (GMT) Received: from li-6bf4d4cc-31f5-11b2-a85c-838e9310af65.ibm.com.com (unknown [9.211.110.209]) by smtpav03.dal12v.mail.ibm.com (Postfix) with ESMTP; Fri, 3 Feb 2023 15:58:08 +0000 (GMT) From: Brian King To: gregkh@linuxfoundation.org Cc: linuxppc-dev@lists.ozlabs.org, brking@pobox.com, mmc@linux.vnet.ibm.com, linux-serial@vger.kernel.org, Brian King Subject: [PATCH v3 3/5] hvcs: Get reference to tty in remove Date: Fri, 3 Feb 2023 09:58:00 -0600 Message-Id: <20230203155802.404324-4-brking@linux.vnet.ibm.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20230203155802.404324-1-brking@linux.vnet.ibm.com> References: <20230203155802.404324-1-brking@linux.vnet.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: ET8Fr26PdPHSkgvIe-XphPXU5J9YaFp0 X-Proofpoint-GUID: CZHFS_v0DnES3af0YDYMJMavJjO2GJFQ X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.930,Hydra:6.0.562,FMLib:17.11.122.1 definitions=2023-02-03_15,2023-02-03_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 lowpriorityscore=0 phishscore=0 malwarescore=0 suspectscore=0 spamscore=0 clxscore=1015 mlxlogscore=999 impostorscore=0 bulkscore=0 priorityscore=1501 mlxscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2302030142 Precedence: bulk List-ID: X-Mailing-List: linux-serial@vger.kernel.org Grab a reference to the tty when removing the hvcs to ensure it does not get freed unexpectedly. Signed-off-by: Brian King --- drivers/tty/hvc/hvcs.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/tty/hvc/hvcs.c b/drivers/tty/hvc/hvcs.c index 522910716025..8d40b20de277 100644 --- a/drivers/tty/hvc/hvcs.c +++ b/drivers/tty/hvc/hvcs.c @@ -799,7 +799,7 @@ static void hvcs_remove(struct vio_dev *dev) spin_lock_irqsave(&hvcsd->lock, flags); - tty = hvcsd->port.tty; + tty = tty_port_tty_get(&hvcsd->port); spin_unlock_irqrestore(&hvcsd->lock, flags); @@ -814,8 +814,10 @@ static void hvcs_remove(struct vio_dev *dev) * hvcs_hangup. The tty should always be valid at this time unless a * simultaneous tty close already cleaned up the hvcs_struct. */ - if (tty) + if (tty) { tty_hangup(tty); + tty_kref_put(tty); + } printk(KERN_INFO "HVCS: vty-server@%X removed from the" " vio bus.\n", dev->unit_address);