From patchwork Tue Jun 13 03:27:27 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Lu Hongfei X-Patchwork-Id: 692852 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 E9B9DC7EE2F for ; Tue, 13 Jun 2023 03:27:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235078AbjFMD14 (ORCPT ); Mon, 12 Jun 2023 23:27:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35854 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233202AbjFMD1y (ORCPT ); Mon, 12 Jun 2023 23:27:54 -0400 Received: from APC01-TYZ-obe.outbound.protection.outlook.com (mail-tyzapc01on2127.outbound.protection.outlook.com [40.107.117.127]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3C46513A; Mon, 12 Jun 2023 20:27:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=cLDuqdJdcLdiGwaYmf1vjW/+iJtjdUBToTxIZ3Zi/9YWMO+fFVpWDwYJYbqfGcfTcOcjYE30nTsr/eTmoJ/DzW9AgR9gXVBbaZuPSYIzrK2lbAlz6w/dJChWAfcRa24iIB0rTELsFgsp/JFbslJoCg0CE8UfxRJ+Om4aRTsJ697QNOkToYzNkKxz1hBgXQ+N6QuHgemOXBnpA2Yw78YV2gzo3FCCDhsxHouwsjt7uoxZ1JvEEXhgvskift4o21Vf9xgEoPlV1lJ7WdyKbjft2Ki52BdI8pThAXdXe3m3w9asLQwcDWuCgca7GOUdZsk2exgSWLfTg6UXGWI/mAPtCA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=zDGOtjFWBz1dVSI7dnBDRMXYhJXY9qa1SyBIuu34imQ=; b=IvCh7hdNy3cveacjzvGxMX2rQABeYqe+4/Orr97eavh73f/wtDiURf5b77bGcdZemGsdayCnSG8CBNbEZSsWSno2Ye38ZRyGDx1iojMS4B53Zr20d696x/t438lAjQX4XqFxeuBgMr+o3IfZ1a+2iMDxNOzR3ANnN1l5kS9EgE05z7q4aJQg1BeY9XTjn7OiizqnRBeYJrAOVgH3F9A2OKb+1O14ensxrPzLaiXG9JPI9fRL+jAhdIug9hcnTVmRlmkq2ltFuu1wri5cu+FgYv8mSb3CAfGUXxFxSrApr/MPWDybXQfU+1t83HRP7CgY2N23YI2Beegdro5LmM2kiQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=vivo.com; dmarc=pass action=none header.from=vivo.com; dkim=pass header.d=vivo.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vivo.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=zDGOtjFWBz1dVSI7dnBDRMXYhJXY9qa1SyBIuu34imQ=; b=pukUosgnNeZbDV5va+ipoQIC6nguvkcsj8sG0yD1hc9QvhrlnuRj6ki5vhgcAUuLERJObJy4HDZknxycmD0gTIci761BmQUh6Sc//RRtsTyhTN/uk6TjwLb/qMN+G1Lg6jv7cgr4g209K5f4tGWBiWUfy3BjC9NyilnmxsbDFbVvNEnPDTifAg60mQajtkfePt2KI9rAduRdkZC3WkofFaEdACUmR6bZLv3YEntF114FT0/QO8dVBgS6qvC6PekfcPWklZFpPbQNm04xH4wrRsTtA42ib6clkgVb5rbEJ03H8s2JwHxczdYgkuX6UBZlwGsutsfDLSFb7E9sQU708g== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=vivo.com; Received: from TYZPR06MB6697.apcprd06.prod.outlook.com (2603:1096:400:451::6) by SEZPR06MB5966.apcprd06.prod.outlook.com (2603:1096:101:ee::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6455.33; Tue, 13 Jun 2023 03:27:45 +0000 Received: from TYZPR06MB6697.apcprd06.prod.outlook.com ([fe80::f652:a96b:482:409e]) by TYZPR06MB6697.apcprd06.prod.outlook.com ([fe80::f652:a96b:482:409e%5]) with mapi id 15.20.6455.030; Tue, 13 Jun 2023 03:27:45 +0000 From: Lu Hongfei To: Mauro Carvalho Chehab , Matthias Brugger , AngeloGioacchino Del Regno , Hans Verkuil , Moudy Ho , Ping-Hsun Wu , daoyuan huang , Arnd Bergmann , Lu Hongfei , Sun Ke , linux-media@vger.kernel.org (open list:MEDIA INPUT INFRASTRUCTURE (V4L/DVB)), linux-kernel@vger.kernel.org (open list:ARM/Mediatek SoC support), linux-arm-kernel@lists.infradead.org (moderated list:ARM/Mediatek SoC support), linux-mediatek@lists.infradead.org (moderated list:ARM/Mediatek SoC support) Cc: opensource.kernel@vivo.com Subject: [PATCH v3] media: platform: mtk-mdp3: Fix resource leak in mdp_get_subsys_id() and mdp_comp_config() Date: Tue, 13 Jun 2023 11:27:27 +0800 Message-Id: <20230613032734.34099-1-luhongfei@vivo.com> X-Mailer: git-send-email 2.39.0 X-ClientProxiedBy: TYAPR01CA0138.jpnprd01.prod.outlook.com (2603:1096:404:2d::30) To TYZPR06MB6697.apcprd06.prod.outlook.com (2603:1096:400:451::6) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: TYZPR06MB6697:EE_|SEZPR06MB5966:EE_ X-MS-Office365-Filtering-Correlation-Id: c8a1b838-2e80-47a4-47df-08db6bbe2751 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ARwZ+AmRwz34Fg0mDgcQjsk/Idhm380ey3pQirMvyZpNf5wPH+r9OsisJOLycEMrQUXzDR+Fvpd+Yikw6WahyvwmJYkuTwVH5k9yo8yKmb+v7atTdp+aJMJYrp+0BlS5JO9O+g1FdBUYmalBhZLUl5WrYE1bXfQue3uiToZ+xVv7xpC95Lg6+VXUht805cUnD9I0WIhZvueR+ugMTv1W7EaDb8+d0y9z2bIOBlvvtAFSNZJJ57Q1Pk+ANmYNp7fyocmPi/keR9IgmhNq6kYZ5jtfp2Ft2u1nq1FgJZK/NyCQVARF/e6pztbffSELp7jLt2bYSUwdZAVRgwUQIT07q0WNDm1uEBllcoKizguOEAJQjkQsH+o77Koq1cxlDKWM822OKAQzWiWjsviKwANj8eNvVTy9DXBUbvbyPvWcX/XhGcbBz35iezxxwgQf3DEB2vF12kVi//fC8UjOF3qWPBTkAjIzTZXNU5xtphlMjmoOR6R7udDqsCk74TbIWYek1+v+gI+OTUiQ6J9as2t5o8OWkNW2MQTQJgM5RyZtFrotn9quzK2m4jk6yJCfWYqSpNEtQs6/Sa39f47JaCwNJURiF2u/2FkTIvNPq9++obE6T/0HfQ9O5nsl6Yt0eStr+bRDGosayZYNnZnmrCBFIA== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:TYZPR06MB6697.apcprd06.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230028)(4636009)(39860400002)(366004)(346002)(136003)(396003)(376002)(451199021)(8936002)(8676002)(5660300002)(7416002)(4326008)(66946007)(66476007)(66556008)(316002)(110136005)(2906002)(41300700001)(6666004)(478600001)(6486002)(52116002)(921005)(107886003)(6512007)(1076003)(36756003)(83380400001)(186003)(2616005)(26005)(6506007)(38100700002)(86362001)(38350700002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-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?= =?utf-8?q?6R5iNH/p8KImAikGeYokybtt2EjPJ6wcIOj0hoZ6vsjEBABBNCtI9dV+oteCTxYcN?= =?utf-8?q?R4q8NEU75Js2ltwjuNbikOBkjTroR+iZ+cfdO07rI32+cRVYxeoNwQoyHPnhhzA2t?= =?utf-8?q?EBbf3dzxxfQryxYcObJ7qlx3GoQM8ccA2AErhB7bUcB5mfmowK1x5IybeGBAdBcp+?= =?utf-8?q?+loqpSgboZdT/3VwoqR5L8KQ3VDy4i/GO2Oz0xpdxA+54Netk2xpxUJESTqBrBY0Z?= =?utf-8?q?9EUGIZBs7JXhgueDDmF8OWBeUfWYM6vtCm543xQWaGdfq4doV+UqaObekswV8w0F/?= =?utf-8?q?bzh0Vfh8OL4YqydTWONAkdlCED3IM4w07CrQuSY4y455RhLmyek9RmtlxSY0s5s10?= =?utf-8?q?E3actc0myBDUNHv+hqPS9lLiJDDfGCZXZxtKFpOyPtnOzwSJq/C8XKnJN8HyMuzQw?= =?utf-8?q?K7l10PT1qeeg+W32ovW2KSdW0YpU/fNpejUtJDnWkQOGvIcPLPDGmBOo1apKarll8?= =?utf-8?q?h2WiuP93j5liEb9zvSAlsoTr6pVba15M0epaGiQ/KIisDN+v+lxgvZcTqbpYVk2cY?= =?utf-8?q?U9WM4XiKHnIBBiOZ9ivmIcxIzFxO0DDl4QENDd/FFrbFWSKiLlylqIdppucfgzcVs?= =?utf-8?q?lJgKq5HyHrQ/VwV7iVxcLktZDL2eiiOytXht4zkm86qt8pJ3cCMieeCFNntvsNg0a?= =?utf-8?q?XeolNOsZg6aY?= X-OriginatorOrg: vivo.com X-MS-Exchange-CrossTenant-Network-Message-Id: c8a1b838-2e80-47a4-47df-08db6bbe2751 X-MS-Exchange-CrossTenant-AuthSource: TYZPR06MB6697.apcprd06.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Jun 2023 03:27:45.2570 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 923e42dc-48d5-4cbe-b582-1a797a6412ed X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: RJrAr029fggGnG9K5YWhoIUoIoTZLmewBBiflsALQi950ADr7H9i3WKhAZwek1HkhRJeTiw2kILFz7UD1dsXqA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SEZPR06MB5966 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Add a put_device() call for the release of the object which was determined by a of_find_device_by_node() call in mdp_get_subsys_id(). Add of_node_put() call for the release of the object which was determined by a for_each_child_of_node() call in mdp_comp_config(). Signed-off-by: Lu Hongfei --- The previous version’s Subject was: [PATCH v2] media: platform: mtk-mdp3: Fix resource leaks in mdp_get_subsys_id() The modifications made compared to the previous version are as follows: 1. Modified the patch subject 2. Fix resource leak issue in mdp_comp_config() drivers/media/platform/mediatek/mdp3/mtk-mdp3-comp.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/drivers/media/platform/mediatek/mdp3/mtk-mdp3-comp.c b/drivers/media/platform/mediatek/mdp3/mtk-mdp3-comp.c index a605e80c7dc3..85c5f89f2ed2 --- a/drivers/media/platform/mediatek/mdp3/mtk-mdp3-comp.c +++ b/drivers/media/platform/mediatek/mdp3/mtk-mdp3-comp.c @@ -892,13 +892,16 @@ static int mdp_get_subsys_id(struct mdp_dev *mdp, struct device *dev, ret = cmdq_dev_get_client_reg(&comp_pdev->dev, &cmdq_reg, index); if (ret != 0) { dev_err(&comp_pdev->dev, "cmdq_dev_get_subsys fail!\n"); - return -EINVAL; + ret = -EINVAL; + goto put_device; } comp->subsys_id = cmdq_reg.subsys; dev_dbg(&comp_pdev->dev, "subsys id=%d\n", cmdq_reg.subsys); - return 0; +put_device: + put_device(&comp_pdev->dev); + return ret; } static void __mdp_comp_init(struct mdp_dev *mdp, struct device_node *node, @@ -1135,6 +1138,7 @@ int mdp_comp_config(struct mdp_dev *mdp) comp = mdp_comp_create(mdp, node, id); if (IS_ERR(comp)) { ret = PTR_ERR(comp); + of_node_put(node); goto err_init_comps; } @@ -1144,6 +1148,8 @@ int mdp_comp_config(struct mdp_dev *mdp) pm_runtime_enable(comp->comp_dev); } + of_node_put(node); + ret = mdp_comp_sub_create(mdp); if (ret) goto err_init_comps;