Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp5233309pxb; Mon, 28 Mar 2022 09:44:40 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzDyIpNiaOZ3IWpurMBdbY69q5VG4r0dzLel69FTmjHsA0Hkk2vCDzFM+qZZS0+0MIQSWId X-Received: by 2002:a17:90b:3a87:b0:1c9:9eef:7a9 with SMTP id om7-20020a17090b3a8700b001c99eef07a9mr24118pjb.103.1648485880516; Mon, 28 Mar 2022 09:44:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1648485880; cv=none; d=google.com; s=arc-20160816; b=R7LVllLpA3BoXNtj3oiFXtHnruhKXcRFmDjn6QEbMzjqVRUsSyOjItP3FU3DDywfch ljqrP9RcVKaZnCj6Oz1eo1c7jckQVBJvbrnsHtKLM0BXje8ow1js84RM87gRIow79lYM FeU2rXeaNZDvv3cYAX50TSvVETfPwN2OOeEb+mRCX4+F/bwB/UqBk7J6tNMt7Cine80I oSfbNLa381qc6MylrE9MU+XFdCRhv/icRG3Yf2QjxVqr7mp4O68+ObIVmFAL7aiLC5zt 4FazRJEMTMXHkvd82gdY6UyQRIEiW+cNxbdQNotyILx3c8aRydiRysAfkceBW045jPiJ BvQg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:subject:cc:to:from; bh=gMIB8LPqJitXfluWNO1UZzyaTqwzU5lhQvTcRmrz5CY=; b=MIEOU7nSXSqvFoF7o9hxRiVLjp+DcQ+2Vihl+vtkRd3FrP1r0slxzp+Idml+FiNbKd +mRhHKvCT6lsBIBZYNaw9yWi2C4YXpBQz1DmHjcnAgll8zH4FW358dnM05P3gVTruseW rkmZWcnHtF9shmXgDBGVs4PIjD00sMc5KUOPmdG7E8gjaJ2aXVvjonnc6el6D1gsNJqY R7m6uPB/ZUVWjwXb1cSjQc+nLVxEWJvRgsTAszLvRu681oxy00fe6dmiRg6GEkBz9vDx sK4CbNUHGnApfLz7JAogOhJEra6JamfUwQwfvgFR+RdEH3qmqXEU4SATWRYiZ1TOuT1S Ne9A== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id p9-20020a170903248900b001561bfa1339si2192249plw.547.2022.03.28.09.44.26; Mon, 28 Mar 2022 09:44:40 -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; 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=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242144AbiC1MB3 (ORCPT + 99 others); Mon, 28 Mar 2022 08:01:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36852 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242112AbiC1MB0 (ORCPT ); Mon, 28 Mar 2022 08:01:26 -0400 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 209EEE18 for ; Mon, 28 Mar 2022 04:59:46 -0700 (PDT) Received: from dggpemm500022.china.huawei.com (unknown [172.30.72.55]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4KRrmD2cyWzCr9S; Mon, 28 Mar 2022 19:57:32 +0800 (CST) Received: from dggpemm500001.china.huawei.com (7.185.36.107) by dggpemm500022.china.huawei.com (7.185.36.162) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.21; Mon, 28 Mar 2022 19:59:43 +0800 Received: from ubuntu1804.huawei.com (10.67.174.152) by dggpemm500001.china.huawei.com (7.185.36.107) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.21; Mon, 28 Mar 2022 19:59:43 +0800 From: Wang Weiyang To: , , , , , , CC: , Subject: [PATCH] tty: goldfish: Use tty_port_destroy() to destroy port Date: Mon, 28 Mar 2022 19:58:44 +0800 Message-ID: <20220328115844.86032-1-wangweiyang2@huawei.com> X-Mailer: git-send-email 2.17.1 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.67.174.152] X-ClientProxiedBy: dggems701-chm.china.huawei.com (10.3.19.178) To dggpemm500001.china.huawei.com (7.185.36.107) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-5.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL,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 In goldfish_tty_probe(), the port initialized through tty_port_init() should be destroyed in error paths.In goldfish_tty_remove(), qtty->port also should be destroyed or else might leak resources. Fix the above by calling tty_port_destroy(). Fixes: 666b7793d4bf ("goldfish: tty driver") Signed-off-by: Wang Weiyang --- drivers/tty/goldfish.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/tty/goldfish.c b/drivers/tty/goldfish.c index ad13532e92fe..9e1168c39e77 100644 --- a/drivers/tty/goldfish.c +++ b/drivers/tty/goldfish.c @@ -405,6 +405,7 @@ static int goldfish_tty_probe(struct platform_device *pdev) err_tty_register_device_failed: free_irq(irq, qtty); err_dec_line_count: + tty_port_destroy(&qtty->port); goldfish_tty_current_line_count--; if (goldfish_tty_current_line_count == 0) goldfish_tty_delete_driver(); @@ -426,6 +427,7 @@ static int goldfish_tty_remove(struct platform_device *pdev) iounmap(qtty->base); qtty->base = NULL; free_irq(qtty->irq, pdev); + tty_port_destroy(&qtty->port); goldfish_tty_current_line_count--; if (goldfish_tty_current_line_count == 0) goldfish_tty_delete_driver(); -- 2.17.1