From patchwork Sun May 5 04:34:43 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacky Bai X-Patchwork-Id: 10930035 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 E5DE6933 for ; Sun, 5 May 2019 04:34:51 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C4BC228844 for ; Sun, 5 May 2019 04:34:51 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B50AC28833; Sun, 5 May 2019 04:34:51 +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 17B4628833 for ; Sun, 5 May 2019 04:34:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725811AbfEEEet (ORCPT ); Sun, 5 May 2019 00:34:49 -0400 Received: from mail-eopbgr150087.outbound.protection.outlook.com ([40.107.15.87]:9796 "EHLO EUR01-DB5-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1725792AbfEEEes (ORCPT ); Sun, 5 May 2019 00:34:48 -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=ANWUEQ6rBQifMaNgnq7/NTxHfRWd6clsc/NPPBLBXS4=; b=RrOWDVO8Do6Z6SZ6E+3YNlkR98l6QqABHfGsvuAMNuYIH7nhuCq2hw0Do7L0yaLk/n4RlbxS6F2hl8Wrj1USRbO5hndIHuPUTENCmx9MIZzztu5Jorm6EWJpfXZyRDQTH0wIhg+92IuqZDo385OtVV5shf4NyJLXEwnyW/reUGo= Received: from VI1PR0402MB3519.eurprd04.prod.outlook.com (52.134.4.24) by VI1PR0402MB3343.eurprd04.prod.outlook.com (52.134.8.143) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1856.10; Sun, 5 May 2019 04:34:43 +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 04:34:43 +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] cpufreq: imx6q: Fix the resource leak caused by incorrect error return Thread-Topic: [PATCH] cpufreq: imx6q: Fix the resource leak caused by incorrect error return Thread-Index: AQHVAvvcgKY/ghVFik+vqE7MN5XPPQ== Date: Sun, 5 May 2019 04:34:43 +0000 Message-ID: <20190505043929.19071-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: HK2P15301CA0017.APCP153.PROD.OUTLOOK.COM (2603:1096:202:1::27) 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: 492b1a90-ee3c-4408-007b-08d6d112fe68 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:VI1PR0402MB3343; x-ms-traffictypediagnostic: VI1PR0402MB3343: x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:3044; x-forefront-prvs: 00286C0CA6 x-forefront-antispam-report: SFV:NSPM;SFS:(10009020)(346002)(39860400002)(136003)(366004)(376002)(396003)(199004)(189003)(36756003)(486006)(64756008)(6436002)(66556008)(66446008)(1076003)(316002)(102836004)(186003)(6506007)(3846002)(2501003)(6116002)(386003)(6512007)(68736007)(81156014)(53936002)(2906002)(52116002)(2616005)(6486002)(8676002)(25786009)(66476007)(66946007)(73956011)(71190400001)(71200400001)(110136005)(26005)(305945005)(14454004)(5660300002)(66066001)(86362001)(478600001)(54906003)(50226002)(8936002)(7736002)(81166006)(476003)(99286004)(2201001)(4326008)(256004)(32563001);DIR:OUT;SFP:1101;SCL:1;SRVR:VI1PR0402MB3343;H:VI1PR0402MB3519.eurprd04.prod.outlook.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;A:1;MX: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: Sa/cgq61mYkfFUB7DXAFp8TcuJysS3Gk056ASLMbTJV95Z7cl8gDM9dyTic9/fWilidM93CBcttDz9k4CvQkN38MFXyXgT1Q0VKnt0xXVwyyGB87h//2xI7sT9grxx+sWnytoz8rA4zCj2LsP3PmBgcI2FByS8fuHGFmj6UUOdL9RPD4tbisUEPdEthibRz9J8uqk2XnvafSsaXW+BCd1Fk77mhL4yKULYgaT4jm0KIPjcuR4WDeyWG5VDhEPvAC7bw6kdDn8Y2f/5SB9/nWqIg4whG3JecJxPGrxerY+SpF9JWkTsgijpr+c31hVR3qIQuZH1e5xwSXlFOrqyN9P9VobPCTXjo2aessY2OORuD9u30vLdbniJtEKKh7Vma9T0xCeJZidkpk9klOe7LpudPR4jMYYEwniLs6JUi9IkY= MIME-Version: 1.0 X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 492b1a90-ee3c-4408-007b-08d6d112fe68 X-MS-Exchange-CrossTenant-originalarrivaltime: 05 May 2019 04:34:43.3483 (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: VI1PR0402MB3343 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. Signed-off-by: Jacky Bai Reviewed-by: Dong Aisheng --- 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;