From patchwork Mon Jul 24 07:16:45 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Peng Fan \(OSS\)" X-Patchwork-Id: 705992 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 2C591C001DE for ; Mon, 24 Jul 2023 07:12:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229507AbjGXHMH (ORCPT ); Mon, 24 Jul 2023 03:12:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52208 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230316AbjGXHMG (ORCPT ); Mon, 24 Jul 2023 03:12:06 -0400 Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05on2059.outbound.protection.outlook.com [40.107.21.59]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 38F47138; Mon, 24 Jul 2023 00:12:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ZVo8Eh8vMJCWX/2yeg1rgLCaV9awA6aZYThGdFuT3LmGV5qISmMkPsNvPILW1RFCTn9ENFOVMaG/ER+mC6LiX3b2NwH7fYCr0pTN56byF5lJYA5pzMM4UmYL4qFRQLnpAWUzH0LtG70v1pACJtZ7Cn78x+k+e7Tc+kTH6/LdyjbeyZl++pQxRpUvJlGMPzLQnXt/n807B860ConqxYy/TEUZB3CVKYUju0JQpmEcVUVqYbsWoEdZsiQlCRqZjEjkwY+7bbTC2y+FYOEzp4jpHAKH+U0TPP896djsJZ8IvCY7HstKw4fGoYnZtWTPE9uFR2snk+7VyU4z0QuPopU73Q== 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=BpgM/QxqMBSlhwHeR6LD7JO8gSW3NgNiREx3H273v+Y=; b=OMay18Cwe/m3q/FV4GZvf5E9m2mUWTrYHd/1gqEfIORJWr7dro/pSf2xQGH0Gw6weL9jFFKh9VLiWbTGQIhKxnnBcfefwq3B3vDDD5gXDLHrIDhYfKgTdGoq/WTC9hqrFubGc1qXvJAVhaW0DGDK2hZinfd9f53N4H9ajyWQrTAOrygpI/iJrAR+vvBypZWu1Uv/UFTbyg2j4+wxF6/bQIPeB8pHrA7rhPY6b3qp0ZFOmw0OXMDZVwL8FsAU+1dCpnOToC4CnBA/KT0sEPT58bVv8I1sMTZjpvfN1lAcXy93DPA7lC2jeWuZxlJDOO8cntoWcgdp6g+LeJruRmBVUQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oss.nxp.com; dmarc=pass action=none header.from=oss.nxp.com; dkim=pass header.d=oss.nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=NXP1.onmicrosoft.com; s=selector2-NXP1-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=BpgM/QxqMBSlhwHeR6LD7JO8gSW3NgNiREx3H273v+Y=; b=dFrduIGJYtHQfIV73btWvTOq8wtnH8GYSVb9Zt7N7PmfW9+2/BmxJ05g6u3rlR53GucWhT6KyV/I5HI6YWLxlOub2ngOsVsKKJ+CRextccJlxHA3VL7BzT42+ERcgqglmacanQWFBfh5zhyBqnAX0pUIU3/57E9dWzNWiqGmHCA= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=oss.nxp.com; Received: from DU0PR04MB9417.eurprd04.prod.outlook.com (2603:10a6:10:358::11) by DU2PR04MB8567.eurprd04.prod.outlook.com (2603:10a6:10:2d6::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6609.32; Mon, 24 Jul 2023 07:12:02 +0000 Received: from DU0PR04MB9417.eurprd04.prod.outlook.com ([fe80::5d6a:ec53:f2a8:5b97]) by DU0PR04MB9417.eurprd04.prod.outlook.com ([fe80::5d6a:ec53:f2a8:5b97%6]) with mapi id 15.20.6609.032; Mon, 24 Jul 2023 07:12:02 +0000 From: "Peng Fan (OSS)" To: rafael@kernel.org, daniel.lezcano@linaro.org Cc: amitk@kernel.org, rui.zhang@intel.com, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, Peng Fan Subject: [PATCH V2 1/2] thermal/core: fix potential memory leak Date: Mon, 24 Jul 2023 15:16:45 +0800 Message-Id: <20230724071646.2744900-2-peng.fan@oss.nxp.com> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20230724071646.2744900-1-peng.fan@oss.nxp.com> References: <20230724071646.2744900-1-peng.fan@oss.nxp.com> X-ClientProxiedBy: SI2P153CA0003.APCP153.PROD.OUTLOOK.COM (2603:1096:4:140::20) To DU0PR04MB9417.eurprd04.prod.outlook.com (2603:10a6:10:358::11) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DU0PR04MB9417:EE_|DU2PR04MB8567:EE_ X-MS-Office365-Filtering-Correlation-Id: d0f1a46e-3a7f-4f48-a9d9-08db8c154759 X-MS-Exchange-SharedMailbox-RoutingAgent-Processed: True X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: EyJIb9HlGPG2bVSrjWlmfVcwr7HcyrOmECyfHBRZX/tK3cnLLH/FO5o3269Agvq+zT8gERuOgMFGc022ampEou0EAWO9kj/5QqoVQ6jrcm9PPjd1wB/fcN52I1I25wyNfJ7XVrhYoQdri3mq0DcbGxPTmTljPfneafreezkH8MU1lcvEKS3xKuNsXCtkR3z9yIuZOcAgraXbUaNBPwd/UmlK9jDc3MxyJc/QfasmD0EH+jMBsuNB/VF+7Z0WIXnaxyBQlvEpYRixs651yA0po2xQ1fQZAbyUK3ruQndz1ysAPmFoLSegXX51vmueNKD3t7ROXnpofBd0mUaYgNPCaKNyRY7HqZBMC4/nfXniRCfaJMaIM9S/JKytajZht5N4lCGdA60P9ZPPSMvaiSiIKsuYvaDhlhkHxWtzRVnqf9gx0FPmPDgeYFxMVL37lU+Vg/YIEqBY06csKK/QHaIbD9jGgrEtC5OcF7O2r9ej/SAPm/8Zn/B4UmQKJdV55FRFUmLFp8bpz0Gmb6DzU2FaVBdGgB2l5PT+SAgfgK2O0QNMD3vtEZoDLI2lh2/TAKJLCKBbGX/okaf0pX0f5AEju+cvD3vJa0+19do3RfmupYCi6vBQXgEl6/aHr0+3KrNq X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DU0PR04MB9417.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230028)(4636009)(39860400002)(376002)(366004)(346002)(396003)(136003)(451199021)(6666004)(6486002)(52116002)(38100700002)(38350700002)(26005)(4326008)(66476007)(66556008)(66946007)(6512007)(478600001)(316002)(86362001)(2906002)(83380400001)(2616005)(4744005)(8676002)(8936002)(41300700001)(6506007)(1076003)(5660300002)(186003); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: ex6S+lKxyoOjzC97gMDgTq60RtgOyxHFRh87Wr9aIA6ua8V46pxdnuERlOepNFCZDuNj5fFuKnYzV0rbW1rIuBWY06CF3qivZqi7+15RoCnUHN9j6iyb6kOZtrIcNAE1ISTftNrUXSP0++Mc7TF/LrxRTNJarhjdrpcHWezJQl9vAnlLdUPQ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XyJ7RWHBokagaQ9qyI+zq5wG59XzFxLFr/yfq6ov6trPbxr39DpY4odEz5EMc9NAWIt+8OZrCck9+sKOY0M0QnLX5GQK6ND1SQpgMkUYM3vfGkKD3jfmvqQF+mtaumIMDcF6mtxvfA542RINlA6zxQF6d2EAJveCqNw1sKGrfoDJ8A6SaL/W/Pzek7thNEHo2qEWfPUs0wl8dSKSsGTomGZ02SpwUzWW8QVvilLsSSxg0stmqJPR9Vl6q+KkVrHHlN7td+l3veo6pc2YEU/Wym20xFFZogYCUTrgl4PD1DJYvY6FAmYcJ6rOU4qUR/BOBZd4eDBL4Vw8I8SJMSTOrJTclmjro6 X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: d0f1a46e-3a7f-4f48-a9d9-08db8c154759 X-MS-Exchange-CrossTenant-AuthSource: DU0PR04MB9417.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Jul 2023 07:12:02.5550 (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-CrossTenant-UserPrincipalName: y72k1n/EETqFFCIZAOwVZQV8t2t0zULj9eyYiHY6+W63iBvzam3mYJ5wnatDiH3DK3XfqH3s+oybOKOorwXCXQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU2PR04MB8567 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org From: Peng Fan thermal_set_governor will allocate memory for tz->governor_data by calling power_allocator_bind, so need free it in failure handling path. Addresses-Coverity: 25777220 ("Memory leak") Fixes: e33df1d2f3a0 ("thermal: let governors have private data for each thermal zone") Signed-off-by: Peng Fan --- drivers/thermal/thermal_core.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/thermal/thermal_core.c b/drivers/thermal/thermal_core.c index cc2b5e81c620..fe5eef149695 100644 --- a/drivers/thermal/thermal_core.c +++ b/drivers/thermal/thermal_core.c @@ -1355,6 +1355,9 @@ thermal_zone_device_register_with_trips(const char *type, struct thermal_trip *t return tz; unregister: + if (tz->governor && tz->governor->unbind_from_tz) + tz->governor->unbind_from_tz(tz); + device_del(&tz->device); release_device: put_device(&tz->device); From patchwork Mon Jul 24 07:16:46 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Peng Fan \(OSS\)" X-Patchwork-Id: 706515 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 10C87C001DE for ; Mon, 24 Jul 2023 07:12:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230366AbjGXHMK (ORCPT ); Mon, 24 Jul 2023 03:12:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52238 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230348AbjGXHMJ (ORCPT ); Mon, 24 Jul 2023 03:12:09 -0400 Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05on2048.outbound.protection.outlook.com [40.107.21.48]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B1080139; Mon, 24 Jul 2023 00:12:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=BqI/3+nlJDIjKf7I5cCQwBTVCTiM4Y/0GGokmQnx5mR3I+IgkVyswgjR/+XlCKjWpQuQ4UMi61a2DnUsl24vTjsJ7saLzxLvckIK/QzJo8NbFk3toGo9SQ17cGvrr2cOiJnaxXDMf28dWlwIufjJpRWKM8WyNeQvnF6JlbtQoK519JVwn0kWKN9AK8LaIMfaOhfKbilgLxwRaj1VXTKzcIq4Kn2Va1UqqTrVDq1KcIACqxv4eh9zV0pBcxcM5oEaVIAuLqDCy4VIb8YE2M7FrMCXcKvrBIGgpOPNoZx6szgB/I1dBxVAXPS7d/4eqOP6uxxoAlglYJE5h6V+RPmiZQ== 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=T5YVifBkDbrDwj57HmtUQ4hsDXAzljRU7zOVccAyGgc=; b=VjltN5s4uwyImbvP6pSxct2XoWt7vqYFEeN+fmq3oscIpqumLgeA20/jDGcCrNO3ALS9kYi6QYFqRh6BZDSBXb5GhZIoDE+cPRZdXcsk5tWC35G6VByngg7lyYzlb1DhTHGPaidDr9I3sWeZhoxklhOVSv+0sk7TuhXdu94fNc78IN4S7vwXQev9m6pdSXm0yYfTIZmQQIjMst9lHkN8dCVQSH443Mf0X/95zUWlTt+ODkPMC2Y+rCY/vHE+WC4t/YTXEGvsQsPU4BcEc20bDDWhtOBEkRh60krcHRF0T6w/JxtZBeBPRb6sONadLSZg/giiIYm9JOBCsRqyGADytQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oss.nxp.com; dmarc=pass action=none header.from=oss.nxp.com; dkim=pass header.d=oss.nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=NXP1.onmicrosoft.com; s=selector2-NXP1-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=T5YVifBkDbrDwj57HmtUQ4hsDXAzljRU7zOVccAyGgc=; b=AI3aOvr//DTwxgpipE64gtG7Amcp/erCV7I0aBfOU1fKT95TD3oiAYyAS3k+vOsRxMwteYf2YUxg/a2/AyHlggfn17kkFIjMVlmKVNvPZ6i6p0gQeQW6w6qMp5snLlE9gsyXprIwjS5e4jsF/R15HffZafw2JD0LjlrO1dvdFZ4= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=oss.nxp.com; Received: from DU0PR04MB9417.eurprd04.prod.outlook.com (2603:10a6:10:358::11) by DU2PR04MB8567.eurprd04.prod.outlook.com (2603:10a6:10:2d6::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6609.32; Mon, 24 Jul 2023 07:12:05 +0000 Received: from DU0PR04MB9417.eurprd04.prod.outlook.com ([fe80::5d6a:ec53:f2a8:5b97]) by DU0PR04MB9417.eurprd04.prod.outlook.com ([fe80::5d6a:ec53:f2a8:5b97%6]) with mapi id 15.20.6609.032; Mon, 24 Jul 2023 07:12:05 +0000 From: "Peng Fan (OSS)" To: rafael@kernel.org, daniel.lezcano@linaro.org Cc: amitk@kernel.org, rui.zhang@intel.com, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, Peng Fan Subject: [PATCH V2 2/2] thermal/of: accessing potential uninitialized value Date: Mon, 24 Jul 2023 15:16:46 +0800 Message-Id: <20230724071646.2744900-3-peng.fan@oss.nxp.com> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20230724071646.2744900-1-peng.fan@oss.nxp.com> References: <20230724071646.2744900-1-peng.fan@oss.nxp.com> X-ClientProxiedBy: SI2P153CA0003.APCP153.PROD.OUTLOOK.COM (2603:1096:4:140::20) To DU0PR04MB9417.eurprd04.prod.outlook.com (2603:10a6:10:358::11) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DU0PR04MB9417:EE_|DU2PR04MB8567:EE_ X-MS-Office365-Filtering-Correlation-Id: a26c39ec-7f44-4d71-33ef-08db8c1548fd X-MS-Exchange-SharedMailbox-RoutingAgent-Processed: True X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 0ywdauVCFAlQE7siJP0W3Yk1Mx4ScIkqBt/e7zYxZuZEJHHopj0J7ZltoI2zkKm1aRvjEgj8IUUdckP+MaaDBwYjZG1xOIHOr+lhwKHLvnjJc9UIRwv1Bld4Uwq3N45LRqqsMjKUUHSG78efzQU6e6PMGkWBQaBYM/Ew0txG2yYwkhWEX7JaWXpNBG1exG3FX6G0EzU31++Igmv7I59E21329fE7gq4kcX7+eHiWdWUaB/G6JgWDn2NlgVUadG+qLXL4nzg65hd5rzIkJXDGhqLMWI2L6ZIUtgiFm8StivTrAt5TF+6jfADHoR3rgNV8kREBUUPBBS/LwvSq2kaAshoY2Wy3v5gfnknrrPywFjfvr+ffAHRsZq+KFaWTdA5YEiZY8aXznWg7+z/al6ME3RFMYe3vMBuNylrKcf2nHXdV5iHH/zAYTybqfIaBTP7cVHUYi9tMfyPGuIhhEtiDJtkAkZfxEHaWjt2pILFQHezaUSsLEGNxhat63PZqMjNPyyFj1ESuabBZhCdmLLwY5pzZIb8M/I+Ou0fKtAmASaLY9LAMqZzbFk3xo4LrUp4O/xZ3f3W8Qxw5p5ImHiQ/zDzFmw5M2L2nEzntqX2pk9dxaKupf32h9cEWznjEUEqB X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DU0PR04MB9417.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230028)(4636009)(39860400002)(376002)(366004)(346002)(396003)(136003)(451199021)(6666004)(6486002)(52116002)(38100700002)(38350700002)(26005)(4326008)(66476007)(66556008)(66946007)(6512007)(478600001)(316002)(86362001)(2906002)(83380400001)(2616005)(8676002)(8936002)(41300700001)(6506007)(1076003)(5660300002)(186003); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Ex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r3JVUQlomV/L96HgJliMl721tYKYn/Rzon1y8a/D72K2bVSHJ847YhhTFGOnDbDgoXdL1N1GYjOun8jmnQDh5rWmaAVZXd8rRFRpq+xN8mqp/N80exuCibL9MghRW41eEwLczwscmbs0ZZjCPdcCopy0ecMr1r04if3JGun6gzkY/ZEEyNiFkkvHmyUPDHpi7knAva+p7l3ESZdpbHiKxyWVvNDQSD+Ld88TvdiQQinrN8xM1bHJWZRuT48yF/axZN5MHl5t0eUeyv0CM2XfKaON+DjWotmcnMZOFyf/axn3DUD6SGS2iXe6LaF4xiQhVHtUk5j69Loy9/+3bVVmiXIkfvalXh1H8jjXHnF8CLy0N/e3GCc35Yd3DV9YUSCbD5n6FrnvayrjYXZrCzgVXKliJHR7qOqQFmI47kwToCC8oTPU8ukUdbe3bQ5T5cfMHvnPzDKVGAO+GCjwBdeCuBdYr4vehXTR3YcoFufT9mfUqlxNSoKFGLPfjd7+ZuzyK6nTq7BHq6Kz273 X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: a26c39ec-7f44-4d71-33ef-08db8c1548fd X-MS-Exchange-CrossTenant-AuthSource: DU0PR04MB9417.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Jul 2023 07:12:05.1298 (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-CrossTenant-UserPrincipalName: X08AwmVH6jBMBzjvtY+F76LkP9JAj1N0tB2pR7zQD1TnNIg5uu2HhOSoSvIlIDNFeRBM39wrM+Hosbdrmd4nwg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU2PR04MB8567 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org From: Peng Fan If of_parse_phandle_with_args returns failure, the cooling_spec.np is uninitialized. So move of_node_put below the return value check to avoid accessing uninitialized value. Addresses-Coverity: 25772185 ("Uninitialized pointer read") Addresses-Coverity: 25772845 ("Uninitialized pointer read") Fixes: 3fd6d6e2b4e8 ("thermal/of: Rework the thermal device tree initialization") Signed-off-by: Peng Fan --- drivers/thermal/thermal_of.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/thermal/thermal_of.c b/drivers/thermal/thermal_of.c index 330690a3a208..4ca905723429 100644 --- a/drivers/thermal/thermal_of.c +++ b/drivers/thermal/thermal_of.c @@ -291,13 +291,13 @@ static int __thermal_of_unbind(struct device_node *map_np, int index, int trip_i ret = of_parse_phandle_with_args(map_np, "cooling-device", "#cooling-cells", index, &cooling_spec); - of_node_put(cooling_spec.np); - if (ret < 0) { pr_err("Invalid cooling-device entry\n"); return ret; } + of_node_put(cooling_spec.np); + if (cooling_spec.args_count < 2) { pr_err("wrong reference to cooling device, missing limits\n"); return -EINVAL; @@ -324,13 +324,13 @@ static int __thermal_of_bind(struct device_node *map_np, int index, int trip_id, ret = of_parse_phandle_with_args(map_np, "cooling-device", "#cooling-cells", index, &cooling_spec); - of_node_put(cooling_spec.np); - if (ret < 0) { pr_err("Invalid cooling-device entry\n"); return ret; } + of_node_put(cooling_spec.np); + if (cooling_spec.args_count < 2) { pr_err("wrong reference to cooling device, missing limits\n"); return -EINVAL;