From mboxrd@z Thu Jan 1 00:00:00 1970 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 5533DC433EF for ; Mon, 13 Jun 2022 13:32:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1359298AbiFMN2Q (ORCPT ); Mon, 13 Jun 2022 09:28:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43862 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1358927AbiFMN0N (ORCPT ); Mon, 13 Jun 2022 09:26:13 -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 BECFF6CAB0; Mon, 13 Jun 2022 04:24:32 -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 E578A60B6E; Mon, 13 Jun 2022 11:24:31 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id F019FC34114; Mon, 13 Jun 2022 11:24:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1655119471; bh=Mi4RI/owKtfMDeXHYwCoLe6+6tQevtazNezpbDFRK8Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=t3CgH6eUMGlTzeGWQlEj2Q0tDDby3d1TDkiZe/IMJS18aQLTzteI6jAWFro1uhwO4 flzvAPocgoj7/hKUln61FN7LxFBkHYZuOQEplp+041FDz1CgIWBW/L6axOnaJ5Bf4r PMcpjO7QZ8J8LMSmBTgRoq+vyaLb344s9NwyxRN8= 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.18 009/339] tty: goldfish: Use tty_port_destroy() to destroy port Date: Mon, 13 Jun 2022 12:07:14 +0200 Message-Id: <20220613094926.790572781@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220613094926.497929857@linuxfoundation.org> References: <20220613094926.497929857@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: stable@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 9e8ccb8ed6d6..c7968aecd870 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.35.1