Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp623974rwd; Mon, 12 Jun 2023 20:12:09 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4VpYtMlaEtc5vs1wX2E6DpeLiWjQfRv6C+hn2vwPv/Nt1nLd/BHvQQ4pOIBiFsc0KF0E6t X-Received: by 2002:a17:907:1c93:b0:97d:f8aa:6d37 with SMTP id nb19-20020a1709071c9300b0097df8aa6d37mr10745261ejc.61.1686625929726; Mon, 12 Jun 2023 20:12:09 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1686625929; cv=pass; d=google.com; s=arc-20160816; b=kJX4rTRmlq/IFp+Cb9D1AheBHuVDGb20Ecl4niAo6O89y2XXvHSL0zjH1Y0r9M/EYx ISOBWzjNFZdgFkTVu6Tio6w32j3LGfKT6uhHMVeX9+cdpYLGB20vAg5whVkFWf8voDzp SFm0PtdHZRUEHZNiOeDkzZibPovY7PbDwP6CChxeUGLgwgUU0hppy95yeFltp0/qSjiO poyQysr3erLX4lAmrN70SMHVNpYWC3QXknOAdYkFzpUjgtJD4QCcmUWT4rSyzNM5ZYIz l77FftvB0WZ4PaS/cFxjXHLsyh3wZm9GUMFVpFmLtwpLWrkDCEYaUPuHwl3qG3VJYlqv yveg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding :message-id:date:subject:cc:to:from:dkim-signature; bh=P1SC9/6V9Q9yLvKFSrzd33BzCPBnAiXkOeKS5R1+NNs=; b=pL16Rhl8C0Zvq47AVWX6MjrHwSG27suYIckHhU04Ua+9jmZktiwHpxuUC8raDCOCNv 44yqXKakf/GFN7u9uKx5yHbtLCMMFXQRtrB6IiDY8rC4xgwaaZhUzjISw++resNCJ0uz 7EjOqBVnH6tjsKB5odMkxdklGXNVhcqVmKIbJNawyfi7TCswoawl1BVl18bfmr3hvpNT 7n4WtKF1BWGbjw85fF03eYi10ooXxF6P0LXxAnSwfRyxW05VQ2gqkRNa/rGkdh4xR+7c YevQRP78otA6XNY699RCO9aNfk0I2u+gUajYnFMU4i15KieKjUsdPwfmX02Us7PMmDPz zeYw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@vivo.com header.s=selector2 header.b=kBQ0tmZ2; arc=pass (i=1 spf=pass spfdomain=vivo.com dkim=pass dkdomain=vivo.com dmarc=pass fromdomain=vivo.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=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=vivo.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id a27-20020a170906245b00b00978923794d4si3096386ejb.554.2023.06.12.20.11.43; Mon, 12 Jun 2023 20:12:09 -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=@vivo.com header.s=selector2 header.b=kBQ0tmZ2; arc=pass (i=1 spf=pass spfdomain=vivo.com dkim=pass dkdomain=vivo.com dmarc=pass fromdomain=vivo.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=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=vivo.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238920AbjFMCzd (ORCPT + 99 others); Mon, 12 Jun 2023 22:55:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50110 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237581AbjFMCza (ORCPT ); Mon, 12 Jun 2023 22:55:30 -0400 Received: from APC01-PSA-obe.outbound.protection.outlook.com (mail-psaapc01on2123.outbound.protection.outlook.com [40.107.255.123]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 379D61727; Mon, 12 Jun 2023 19:55:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ewR1mlNic77KumcEz6eBccHYr9KJbUfD1RjnJ0akIZgWUIEyV8CbW+a3qAT+Se791oNgA0OH5LfHEjUgloVbjRxaIzyLCdODyKq2jCqGShsdl7cj0pciY5Z29aYoa0VP03AmXi4tJkNS+BE/6HjPH0gUGpSzuFm1Pe0C04FanOvPBPCPTdhBDcXmA/PjcsilUQzSrYgaMEoD78DfM4o21O+1YnLyJY/MgB8hpW8OysVaskgN27n+mylm9wBh5hFff5LZo0MS1Fu75vOkgB25QQzRwhXIHfmo02WYSNa4hLGt84IbemqdZ52efE7KHSRi+HPnGCcmVuMdyU0MiTYapg== 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=P1SC9/6V9Q9yLvKFSrzd33BzCPBnAiXkOeKS5R1+NNs=; b=hXsf2AvKZZJISI4wWj0E/WpvoTnQ8md5uwcL51P7Cg7PCApov7as9fBe1QmKFBsqIq3RLaO0lazKaR/yFU0Cddxj/AxqpAEUJJp7L+Zqh6UBkWYo55W2ZsnTQfMG64EWghowlFoEwUIJ6xq9X8aQObhIN0YyIn1vIhswRivKn0UekLvguA4rp5lxJpYuAizawkI3H2nyRWwuda4T3rCbiHlMxdYVRPmX03lZozOSmW1ZsMon2KcdOAxMkyHIipuwZ4TDLNRUWdIKkffUwqFf+u6rtmjqtPk2Q6/RGlG0+gr0c1bp9hBxJDRNQeuZxjnDRpJeafiBYP2t9lEqwBkBmg== 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=P1SC9/6V9Q9yLvKFSrzd33BzCPBnAiXkOeKS5R1+NNs=; b=kBQ0tmZ2WIut6pumheNtKwlyB0jp+qQstODI9gyE+e2XdHX2B1MbT9FenbVXRIUYQCdQMUbluFn+f0HDSClDUJzaShL6po8GVg3ayBFyfgQQQug9hiluZksnedPI23cQc2vncB75E9TWSQy4pqY8AeWq3IMXuVbrP0WmqnBT3fEAH4BRHs0N6qdqeZZpljHpO9qJF9S2mftb+QK35o1EAAwZKeBzpwL0wk7CBq5brDYdgSBAi6u0GIQJU2+emk5Z2LyXcuHVC2b7IwzVK6Y0SNElXtFOhH/n9jU5NCSsTzJbmmEoKvzi/Z4EthcaeUNdMGWLLCPCLIsVlJH8WJ2fLA== 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 TYZPR06MB6418.apcprd06.prod.outlook.com (2603:1096:400:45c::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6455.32; Tue, 13 Jun 2023 02:55:25 +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 02:55:25 +0000 From: Lu Hongfei To: Mauro Carvalho Chehab , Matthias Brugger , AngeloGioacchino Del Regno , Hans Verkuil , Moudy Ho , Deepak R Varma , Arnd Bergmann , Sun Ke , Lu Hongfei , 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 v2] media: platform: mtk-mdp3: Fix resource leaks in mdp_get_subsys_id() Date: Tue, 13 Jun 2023 10:55:06 +0800 Message-Id: <20230613025515.24512-1-luhongfei@vivo.com> X-Mailer: git-send-email 2.39.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: TYCP286CA0192.JPNP286.PROD.OUTLOOK.COM (2603:1096:400:382::18) To TYZPR06MB6697.apcprd06.prod.outlook.com (2603:1096:400:451::6) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: TYZPR06MB6697:EE_|TYZPR06MB6418:EE_ X-MS-Office365-Filtering-Correlation-Id: d3884ec1-da1a-4fe4-0990-08db6bb9a336 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 4TGleOyQF8VcsO8q7c9ULiyqmELaTQJzV+PMyB1tRBxLdilsQhUZJrFuw3T0q+5nCxFq70Fl3AzAon4WvYvcc7qshxmDa61vY7lmmkl8EDiAaY23Anck3bQgODdOS6Py07A3Wbhmupelr6QI6ijc25qmvJlmuHv4IZQvwCrtlqb9Y4VmEDNKlueIvBwGt5nLZpHcjFlariy50dkczSyA5xqlHQR4L/RhaVbBKkNumCKspwKKz6+LFbObmepzdtONhiQv+EZlE+0gPLPLXX/s4H7cyYJnWSUyyvay9qFZ2/TmOzS2P68JzYzd+Syv2RKB6bpzqd2zrEve78ysmryHfKEic+Pk4LpAFz9XBt8Q0MFn156pFGtQJDWzeXKxniJcmenAPAZWcJqL+4vK9P77pM7nKL5sCA2KRt6eJD/ZSKS0c2qUufgeF4Q7HPKZ6fSn9fzng64lRSs6StqlJ/J5Aya1/X4dcZ0Dbj/xgzHroJG3XqC0MZpuAwTXSDIUBmKiG6weT2ZdOEPj1GuffKRmImId4CxSkqmggwb9/KBJdYWj2IM7zfyRVijm7IVQSyNSuw1Ol0zAMKr4l1ueAX+3cWEAbprCJ/o2pDAmHwqiGQVcM2J0JB2JcCa5ePNU2atqNSvmiU8dkuM8Dg9dCSxKlA== 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)(136003)(366004)(39850400004)(376002)(346002)(396003)(451199021)(83380400001)(107886003)(38100700002)(38350700002)(86362001)(921005)(478600001)(6512007)(52116002)(6666004)(41300700001)(110136005)(4326008)(6486002)(8676002)(7416002)(66946007)(66476007)(2906002)(316002)(5660300002)(66556008)(8936002)(2616005)(6506007)(26005)(1076003)(36756003)(186003);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?nWhv4lchVax53ZjlVwP6qvuAyNl1CDqjjZmgpgO+07dNrng3yl/BKNTXSHKO?= =?us-ascii?Q?AxyBnQMYjanSRdJm2ZbOmBObksnUKuYgB+YOdWAnlKrU9lpX//TILq+Jk+At?= =?us-ascii?Q?kaNhs/Hhz8KjgmEhSWaV6jCyJCR6U1arHlXWln3+phY5AmSTTgPjYBZgowPS?= =?us-ascii?Q?OMta1rjuVE42snGPR8gTBYtr8dt7e012LqwNXhQcYI/YrWWe24lR01C8iLzg?= =?us-ascii?Q?g9hkQHoR91vxcIvWLxc50LLkvs2aP/5uZV4OBxmB6bzh81S1jLUx0vKuQq9O?= =?us-ascii?Q?bKQ+Moojzgy1q4nEP4YsY0tE8ltxCqGKOJsXDGKKDLxQqyq3GAe4rHpCjF5q?= =?us-ascii?Q?ICa3MmYF+/8JuGZsQX/WdXcJvE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TWG1ziesYQBUMs4a8EAYk4XiMQZSqiwf5snAdQ8Vb4R9ovDcCMdVoQ5i?= =?us-ascii?Q?gO+icpvJCB0du5K4xjv/Ke2Ji0Ao2pXxLAc008O1/5KKsDXdKkWYxkdJS5WY?= =?us-ascii?Q?Wdf8H4Ych6vhbkSB8BBoSmEUYMBi8X5p0Anq6j57BlBcU1SQwTuXwenT0C3J?= =?us-ascii?Q?+0KeGP37ceKWanLfixG5+f2bv1IYZ3SQh8LcEp8gdBnl09fH0/3Yqcr+BUT2?= =?us-ascii?Q?/AWZfsHDr6GBuvHW8uWDEgINRlekD+8huEoA92aAdXzea0TVBkOMIFG4IqCg?= =?us-ascii?Q?hhycAYynnMSlqTIfhgYwWiw8EWBgnt+hw3NeAZ9f?= X-OriginatorOrg: vivo.com X-MS-Exchange-CrossTenant-Network-Message-Id: d3884ec1-da1a-4fe4-0990-08db6bb9a336 X-MS-Exchange-CrossTenant-AuthSource: TYZPR06MB6697.apcprd06.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Jun 2023 02:55:25.6574 (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: b4JkDjssdTeHaI9mRyTwhEn0oqEQ1VbcodUKYMQu6WR+mI3i2sVzqo3hX0rLtEBIQq+ad6np21wpdCSTyFuE4w== X-MS-Exchange-Transport-CrossTenantHeadersStamped: TYZPR06MB6418 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS,T_SCC_BODY_TEXT_LINE, URIBL_BLOCKED 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 Add a put_device() call for the release of the object which was determined by a of_find_device_by_node() call. Signed-off-by: Lu Hongfei --- The modifications made compared to the previous version are as follows: 1. Modified the patch subject 2. Modified the commit message to make it easier to understand. 3. Use an additional label "put_device". Increase the usage of the variable "ret". drivers/media/platform/mediatek/mdp3/mtk-mdp3-comp.c | 7 +++++-- 1 file changed, 5 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..ec39662a2282 --- 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, -- 2.39.0