Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp595518iog; Mon, 13 Jun 2022 08:49:34 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwF0zoz5RytOA4csqMaulJwynOGqr8r62YpB5RSqnGSgDi49k27Zvs0Y6xGR7elBEkbXVhe X-Received: by 2002:a17:90b:a85:b0:1e2:e062:95ba with SMTP id bn5-20020a17090b0a8500b001e2e06295bamr16526216pjb.211.1655135373969; Mon, 13 Jun 2022 08:49:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1655135373; cv=none; d=google.com; s=arc-20160816; b=d3fD+VMb2uKDKr4ZH/I4Jf2tjjX8yy8tU23Phzrg32fpYdMqqVJKNaz1u7f7WZmNPt NIV/PHvAbo+5UayA3aGzQZ3CgkNE6ZYj/cxzjN3MEFsIrugzpAJbRxa/pjEamhADdzuX 5SxpuzLdYWeqbLOrkM+EXQLtFl1D9rLoZnr761vFTfw3+YVO+TPLSGegnGaXhpzYBu9C xCz5Y5hQpjJipIgAa4A5JrxxUEzdUOmGT/3QZ8osNCpBeg4PJyq4P3LJKgT/IEnQludk gubjoAd7hdVq2CzHZXE6ct6cYgOyn6eZKXQY2FrkPcW8iqAbSm+C6dSJjyux5TJgHMku kP3w== 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=I5WNerlrjA1X29CkveicRbqjD1CofLto3m8R+oxZmf4=; b=xD9UB4Bt0lMxOK02/RRrnjnXREF45mA8tPDfd9YeK2OHJgZ/EWI38a9xvrI6WRWBiy tCzZtEGEH6+irggW7gwU51ElNVZuae4jlkp1BTYsvWb+RXxKDEUe8ZponkDb2rVFq843 7BLZ1798znde31b48SI17JAf3slx1WQycUa13IBfMu1jpVA6/jxF8YBsm/2/vVYkCyT4 IutsujIR8god4OhDS2ZRfLSWj3I3BtsMFqs5w3Qq7UTGvIVvJo5TTC7p8vnd9GXF5ID3 1IZbXMTZPWQXR2viugkDM11BtGP8sQyAbMUBjTVtZi81o+VlZeytgk6oKdO1Kmu5cWB7 woTw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=iXaz85ir; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id x3-20020a170902ec8300b00168a4ef6a67si11980266plg.17.2022.06.13.08.49.16; Mon, 13 Jun 2022 08:49:33 -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; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=iXaz85ir; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1354506AbiFMLfU (ORCPT + 99 others); Mon, 13 Jun 2022 07:35:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56186 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1354427AbiFML33 (ORCPT ); Mon, 13 Jun 2022 07:29:29 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1EE22D118; Mon, 13 Jun 2022 03:44:22 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id B1D656112A; Mon, 13 Jun 2022 10:44:21 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C191AC34114; Mon, 13 Jun 2022 10:44:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1655117061; bh=go+bLNCXMVhWeT4gE5HjpGEJBCskRbxmxK2/0B/cnJY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=iXaz85irC8LawM5pxYG7E9nVWVi5uQifp1bb3QYb44b+k96gQlmEMSnZZ25S4gPYm X7XzOUAB0dbEybVkjdGG6QJCDJnMuRYiP1a/yCCyMeX2d87rZNyiUdE592UqPtWKu7 YOlD+sdE3gB28ppIYJb+c8j/XNxeLnUykjIU9cH4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jiri Slaby , Wang Weiyang , Sasha Levin Subject: [PATCH 5.4 284/411] tty: goldfish: Use tty_port_destroy() to destroy port Date: Mon, 13 Jun 2022 12:09:17 +0200 Message-Id: <20220613094937.273703259@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220613094928.482772422@linuxfoundation.org> References: <20220613094928.482772422@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-8.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, 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 From: Wang Weiyang [ Upstream commit 507b05063d1b7a1fcb9f7d7c47586fc4f3508f98 ] 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") Reviewed-by: Jiri Slaby Signed-off-by: Wang Weiyang Link: https://lore.kernel.org/r/20220328115844.86032-1-wangweiyang2@huawei.com Signed-off-by: Greg Kroah-Hartman Signed-off-by: Sasha Levin --- drivers/tty/goldfish.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/tty/goldfish.c b/drivers/tty/goldfish.c index c8c5cdfc5e19..abc84d84f638 100644 --- a/drivers/tty/goldfish.c +++ b/drivers/tty/goldfish.c @@ -407,6 +407,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(); @@ -428,6 +429,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.35.1