From patchwork Sun May 5 08:02:48 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacky Bai X-Patchwork-Id: 10930079 X-Patchwork-Delegate: viresh.linux@gmail.com Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id EA417933 for ; Sun, 5 May 2019 08:02:54 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DA96C285D1 for ; Sun, 5 May 2019 08:02:54 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C7D1E285E0; Sun, 5 May 2019 08:02:54 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7242F285D1 for ; Sun, 5 May 2019 08:02:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727232AbfEEICx (ORCPT ); Sun, 5 May 2019 04:02:53 -0400 Received: from mail-eopbgr150077.outbound.protection.outlook.com ([40.107.15.77]:47117 "EHLO EUR01-DB5-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726310AbfEEICx (ORCPT ); Sun, 5 May 2019 04:02:53 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=gjuzFV7a9sIgcJgmTqibTtxLFuGtK/9z7b50oy4mXXo=; b=x6htGMd+xvsJjUby2r1zUbUHjC3jaP5JAmly2Jz5QAhhrUrrlGeyxUBkQ6UqeR91kXh4VcTXDhbg2pgAKODveikBmva2KG9L7PTIce8F8J377m+X38a+oD5fA9BixPL58zMaq6MDniEL06OoU4eYMvGPBocW2eXpBKo5axfpu5I= Received: from VI1PR0402MB3519.eurprd04.prod.outlook.com (52.134.4.24) by VI1PR0402MB3584.eurprd04.prod.outlook.com (52.134.5.16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1856.11; Sun, 5 May 2019 08:02:48 +0000 Received: from VI1PR0402MB3519.eurprd04.prod.outlook.com ([fe80::f830:3f53:72c1:b14f]) by VI1PR0402MB3519.eurprd04.prod.outlook.com ([fe80::f830:3f53:72c1:b14f%3]) with mapi id 15.20.1856.012; Sun, 5 May 2019 08:02:48 +0000 From: Jacky Bai To: "festevam@gmail.com" , "shawnguo@kernel.org" , "viresh.kumar@linaro.org" , "rjw@rjwysocki.net" , "s.hauer@pengutronix.de" CC: "kernel@pengutronix.de" , dl-linux-imx , "linux-arm-kernel@lists.infradead.org" , "linux-pm@vger.kernel.org" Subject: [PATCH v2] cpufreq: imx6q: Fix the resource leak caused by incorrect error return Thread-Topic: [PATCH v2] cpufreq: imx6q: Fix the resource leak caused by incorrect error return Thread-Index: AQHVAxjtnjxGnDga/EKgfP3NYCr4Xg== Date: Sun, 5 May 2019 08:02:48 +0000 Message-ID: <20190505080736.27970-1-ping.bai@nxp.com> Accept-Language: zh-CN, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-mailer: git-send-email 2.21.0 x-clientproxiedby: HK2PR03CA0062.apcprd03.prod.outlook.com (2603:1096:202:17::32) To VI1PR0402MB3519.eurprd04.prod.outlook.com (2603:10a6:803:8::24) authentication-results: spf=none (sender IP is ) smtp.mailfrom=ping.bai@nxp.com; x-ms-exchange-messagesentrepresentingtype: 1 x-originating-ip: [119.31.174.71] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 175fe945-3197-48cc-5101-08d6d130100b x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0;PCL:0;RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600141)(711020)(4605104)(4618075)(2017052603328)(7193020);SRVR:VI1PR0402MB3584; x-ms-traffictypediagnostic: VI1PR0402MB3584: x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:3044; x-forefront-prvs: 00286C0CA6 x-forefront-antispam-report: SFV:NSPM;SFS:(10009020)(396003)(136003)(366004)(376002)(39860400002)(346002)(189003)(199004)(4326008)(102836004)(86362001)(71200400001)(316002)(110136005)(54906003)(71190400001)(2201001)(53936002)(66446008)(1076003)(50226002)(68736007)(66066001)(386003)(6506007)(8676002)(2501003)(476003)(7736002)(2616005)(8936002)(305945005)(486006)(81166006)(81156014)(6486002)(52116002)(478600001)(186003)(256004)(26005)(3846002)(6116002)(66946007)(66476007)(64756008)(25786009)(66556008)(36756003)(6436002)(14454004)(6512007)(5660300002)(73956011)(99286004)(2906002)(32563001);DIR:OUT;SFP:1101;SCL:1;SRVR:VI1PR0402MB3584;H:VI1PR0402MB3519.eurprd04.prod.outlook.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;MX:1;A:1; received-spf: None (protection.outlook.com: nxp.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: XFm9RWRAIDesOSvgVlRA+mA/p1GKSrdBBn6L7oa/LEx+IbfOdFHwuWZMjuUs9LMWI2KhhJEzWpYNUt4LjnnHuSWcjz0o2mgP0+wI/7/q6533ZpI3KtDm5xoz1izgzOT7Dw+0Q2PxN+bO0fGs5y8FdvtmoyEICg9e7W5M8H8nU9u3k8gN+stpRpNuDv+HXki1JtUOhTXN5PD/edpbLnPkiK9uAz8ybSpaeyijIzFSU3dNEUXCGjGfg3cvx3Jr/KI7tUeXlXXr6Z6uY12pnG7Jd4+5thb6BL6FLBn+aX16wT8f3Ca4FmYl7M5rNDitHcnr0llICDnfKKmCwG0Ps0Xaqlzn6AtA3Nib9lU/CaOoRTorks0l6Fi1EPavW2CrrlJpbaAiqeKkHbEN7lGYTSLIg3pokqt+gRMCL0R+ge5jrsQ= MIME-Version: 1.0 X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 175fe945-3197-48cc-5101-08d6d130100b X-MS-Exchange-CrossTenant-originalarrivaltime: 05 May 2019 08:02:48.0578 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR0402MB3584 Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Previous goto only handled the node reference, the opp table, regulator & clk resource also need to be free before error return. Fixes: ddb64c5db3c (cpufreq: imx6q: fix possible object reference leak). Signed-off-by: Jacky Bai Reviewed-by: Dong Aisheng Acked-by: Viresh Kumar --- drivers/cpufreq/imx6q-cpufreq.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/drivers/cpufreq/imx6q-cpufreq.c b/drivers/cpufreq/imx6q-cpufreq.c index 3e17560b1efe..1d4ecefaabc6 100644 --- a/drivers/cpufreq/imx6q-cpufreq.c +++ b/drivers/cpufreq/imx6q-cpufreq.c @@ -383,23 +383,22 @@ static int imx6q_cpufreq_probe(struct platform_device *pdev) goto put_reg; } + /* Because we have added the OPPs here, we must free them */ + free_opp = true; + if (of_machine_is_compatible("fsl,imx6ul") || of_machine_is_compatible("fsl,imx6ull")) { ret = imx6ul_opp_check_speed_grading(cpu_dev); if (ret) { - if (ret == -EPROBE_DEFER) - goto put_node; - - dev_err(cpu_dev, "failed to read ocotp: %d\n", - ret); - goto put_node; + if (ret != -EPROBE_DEFER) + dev_err(cpu_dev, "failed to read ocotp: %d\n", + ret); + goto out_free_opp; } } else { imx6q_opp_check_speed_grading(cpu_dev); } - /* Because we have added the OPPs here, we must free them */ - free_opp = true; num = dev_pm_opp_get_opp_count(cpu_dev); if (num < 0) { ret = num;