From patchwork Wed Jul 19 01:16:35 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: 704531 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 862F4EB64DC for ; Wed, 19 Jul 2023 01:12:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229458AbjGSBMB (ORCPT ); Tue, 18 Jul 2023 21:12:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60666 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229715AbjGSBMA (ORCPT ); Tue, 18 Jul 2023 21:12:00 -0400 Received: from EUR02-AM0-obe.outbound.protection.outlook.com (mail-am0eur02on2071.outbound.protection.outlook.com [40.107.247.71]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D6F081BC9; Tue, 18 Jul 2023 18:11:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=i6Se0zxmMZP6e6wvdF2LztD94HrlWE/NNezxCzDz6T5EHoKoD3BJrIYNVg22AIooxsDqLzrvziwDu65Q1357vCyoP8VtUCm9nnKg0nWV/Ig0IbWdrDBqxv4f12zrcIKJMVWCQp1DbRhOqkx0BEVXFUzTFDoK1/bXQmIT2OS/X4L1Z3ngEpodOMcMKZ913EWW71SvqN4xbW37cDiL/DJyJljjpFUAZcpG1mfRi1AYclarrn17yGCvTYZHV/3fBE25n9Sncihd5TJIZzqUwsbeN7R+hv/d3bO5666ewmfL5cUS5HkVdo8NIYo1AbktT5AaVbV88gqUzpt32WlbFkBYRA== 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=8YdJE14hjgBjyXhHdAsfdg8EEhwsNTnfGGnBSmKcx4Q=; b=PsKbicV/7jt0lV0yfug3/qiiTG8zWrvtcOOBkQrgty7Jt1x2d9DNQal8YaLY4Gg2VIAu7RLruc1hz3dBoaSzjN15y5xKcQcUg5dw5b9hgh21dgP/SxhlVsbwwq5398moEV4tZzk80096KF6qFjqMr9RQQKgGwHzutgMJ2NzVOjmbdKOWr9Og3k51Oi6s9HIvoPrLFV5izNincGchZD4jukGFG0ZRnKjGYqdhKAbabe7LYMdGGo0cEHLgubymU/9aU6ZZIf3D9OUZb0NVWi294aafwdi+ih9xBmXvwvrppZeS4ZLXXP8y6yXHr6XNPorjZ5IDSQjGWrAOlSejzmUEww== 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=8YdJE14hjgBjyXhHdAsfdg8EEhwsNTnfGGnBSmKcx4Q=; b=U8WbaxZMLSVeA8dHr/iwgyV59tTxlq6TPENnc9YedW8iXpyogDajkS8sJWH3+Z/f/U6mrpWs8oExPjRuGelxuLhh6rROcAz0OIBJgtzFFDm4w8FmWfXcZrVrtxcb7Qw6ubCKVyrKt1tO33SmLHJ5WbBLkuWvljUy4LMLuDDFs74= 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 DB8PR04MB6921.eurprd04.prod.outlook.com (2603:10a6:10:119::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6588.33; Wed, 19 Jul 2023 01:11:53 +0000 Received: from DU0PR04MB9417.eurprd04.prod.outlook.com ([fe80::c874:7c87:c13b:64f8]) by DU0PR04MB9417.eurprd04.prod.outlook.com ([fe80::c874:7c87:c13b:64f8%5]) with mapi id 15.20.6588.031; Wed, 19 Jul 2023 01:11:53 +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 1/2] thermal/core: fix potential memory leak Date: Wed, 19 Jul 2023 09:16:35 +0800 Message-Id: <20230719011636.2893238-1-peng.fan@oss.nxp.com> X-Mailer: git-send-email 2.37.1 X-ClientProxiedBy: SI1PR02CA0034.apcprd02.prod.outlook.com (2603:1096:4:1f6::10) 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_|DB8PR04MB6921:EE_ X-MS-Office365-Filtering-Correlation-Id: 4db0c6ae-d3ed-49f2-cc87-08db87f52332 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: VmIurcHfsbghv3WnAkp/f9RrloLIpgF//k0JLpYyG+Ko2F38nr8ju9/bSWKsJH1bCbpikF3f+8I7dIXUiMIkyO9va+7RxUb4GjV6Ypr8ERN041rJm3LQiQGDGIbQypsKQoTKSK0jGSRdTi25IZ4KqoRiTc42JHaKH9arI3OpbU1tmD/KN879MbEIwUMVN1u8HR9FonxE5l4qHov8DcuWGDiWNr9yHKiIMNZWmbz8lDvXQgiGvZIJA3ZIIDa1lHD37bIENE06LWpmCJSQXpVBqgmACpVG5FTceGcQEwhvk+1jCNKtpr9VnPrC03Rauyi5XHotOPsuk8QanrUWfq8MrRwJzk7H/N7Gk+DeVyaYgEy7CpRMB3J4aOp/Tm9ZAX+P2PSFpfqooUKw1ZI0UMAL2gzcj69Vlpf6eEvIW5EbjTjOKF7kWhy2UrHJkjVygkH7V4VzDmThIgOX50p82L8TPLXEACO0BDnRPRva2QFgy46eQE6GwXYZzuiB34OQy8W9YYn4UAovPETzOtBt9WhY+UJS+7RM4QKjhnYPNNXI9E/AlnlOQBrKVidZF2V7vUIiwaaKJQubyO0IIHHsZlvxinmuI8HIw8QUgddKW1TnV7zeJaxpvQtiBXidPIFvtP/Y 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)(136003)(366004)(39860400002)(346002)(376002)(396003)(451199021)(38350700002)(26005)(6506007)(38100700002)(1076003)(186003)(2616005)(2906002)(83380400001)(5660300002)(4744005)(478600001)(6512007)(86362001)(52116002)(6666004)(316002)(41300700001)(8676002)(66946007)(8936002)(66556008)(66476007)(6486002)(4326008); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: cYI7xE0SBVq0KhSWXZ3dNDb9V71blq44gAdXQUVfF6nZ3N0l6ibpOdcg1niN2Tir9RhVU7GFF4LSDNMgbIjLmoeiXBIajnjsIj8Fl6GWB/ED/2iGQC+xm6Gni0T82MmBMdz95ceIivYycL23da/nBH0E3IFPcAlWuwbIrHwnKWGAtSDZad4uhbsK6YkssGoddVPFNLqohC9WnFnZ0DkE3lTBcfVfCxImXeMsaEKaDUI4/PtGGkbXGkp0ziMvSHTfN/cL+XpED5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RJWzYfRgG5uKEU6h10wVVc9AO/YoMxEcRumk53v2CPwdsnuUsZSzAQ563RPzQ5x2zWNrD8KPSmZ/sABuEX/NErKAm+biDxgvq/0Nzr3fxLToZboPk/cl10w5XrovZNzAXQYQ6BahuuOhffpCEqbZagbL7oOFnOkiPtdRWwapP75fVDB8wO7AXv/f45XnW8Iw/oxj8dNssjqbVp3VShXUmK84njx/2KKfFHQFNAMOpRezvh57G3fY4SHnKIo2Uhbmpn/aj0B7SR X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 4db0c6ae-d3ed-49f2-cc87-08db87f52332 X-MS-Exchange-CrossTenant-AuthSource: DU0PR04MB9417.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Jul 2023 01:11:53.5780 (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: MS8Ufs5nv3NIsyX8l6gseIMPXpSOFbVfpnAmxXbosIpoRuPjAQD74RpDipWXMmiyabvk1tobsb2zBv3AjP8c7A== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB8PR04MB6921 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org From: Peng Fan thermal_set_governor may allocate memory for tz->governor_data, so need free it in failure handling path. Addresses-Coverity: 25777220 ("Memory leak") 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 842f678c1c3e..f633924406ad 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 Wed Jul 19 01:16:36 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: 706048 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 01338EB64DD for ; Wed, 19 Jul 2023 01:12:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229887AbjGSBMD (ORCPT ); Tue, 18 Jul 2023 21:12:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60684 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229894AbjGSBMC (ORCPT ); Tue, 18 Jul 2023 21:12:02 -0400 Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05on2063.outbound.protection.outlook.com [40.107.21.63]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E54D61BCF; Tue, 18 Jul 2023 18:11:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=nyG5TfTZnzmXZbhP4oNgjrMZY332MmdmE+FmuRwKo2wBX5z8qf0OQ5NCAg2qDl42NX4lpMXGoogNbc+MvMO4q4/EVa5wkKcFWFhuUryapklouOPV/JGh86btr7meBr+d/ERfrnBO5Etuq30pD7s7UGBzGwdOrVXS4E3rCt8JzmaLE4zA8b3YBuk1y3Nfo7XyY5K5No9b61ebeSic5JETLKkCvhLiHMA0sZQ0BSCi8DLaMgqpVCrEpMgHbwePyCK7aGJFsW4oGjBylwUboPmlYsaf5siKJ2UYL8Hi3OMpk9+NIXuK8gAVxg1+6+75HgLmlqFo7ecvBTN7Nr4+Rl3iNg== 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=7wcF9zFZNpBVDma/sd1rfbuadC8esQz307gzkbSEj6A=; b=h2s2GsLjqoMgZsnrdm3A/RWpPrCxtuetEGKDp+ohSuCxIfR/pS6mI2bH9Pa6JLHVhaOIy1Cd4hYHyGv+/RW/T+1Overuuo0TDW6proc+gafqcUdt6gYCQxnXn1lBmMyfFz1UY8KEPnQ2TZ+y5rTEA53M8wbERe+A5R111y+SNUHBYnNqD6zrAJitU3gXu+3LofOwLSbYiRBpGXxJbRYQxBw9wWL89J4awItO8ACC1p24EhivMVmRuA+iofP+pwuRJeucyeXB2Jgg2qjbbzpxnv/zLqtP9tPg7hgo3r07nEXm3CQ9SXo03Mt3wo4p2o8Cw1wcJ/EvJM4PjoqMwyHYsA== 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=7wcF9zFZNpBVDma/sd1rfbuadC8esQz307gzkbSEj6A=; b=GTroljH/Vr+rgZUDvY3IO3lTR+SYn2f4Xq3Aumme+q44BMwcIleLe9QdKPhWdvs8m7QWT8vizUfHPcujs2cgzcDTjssdvlRcQS+K3y7ZkwKn06L383HpD0HGlrhhWjieqzwZq1Q94KK5Zq8blhdkclE4PUvodVTARYdscv7Bs6U= 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 AS8PR04MB7558.eurprd04.prod.outlook.com (2603:10a6:20b:23c::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6588.32; Wed, 19 Jul 2023 01:11:57 +0000 Received: from DU0PR04MB9417.eurprd04.prod.outlook.com ([fe80::c874:7c87:c13b:64f8]) by DU0PR04MB9417.eurprd04.prod.outlook.com ([fe80::c874:7c87:c13b:64f8%5]) with mapi id 15.20.6588.031; Wed, 19 Jul 2023 01:11:57 +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 2/2] thermal/of: accessing potential uninitialized value Date: Wed, 19 Jul 2023 09:16:36 +0800 Message-Id: <20230719011636.2893238-2-peng.fan@oss.nxp.com> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20230719011636.2893238-1-peng.fan@oss.nxp.com> References: <20230719011636.2893238-1-peng.fan@oss.nxp.com> X-ClientProxiedBy: SI1PR02CA0034.apcprd02.prod.outlook.com (2603:1096:4:1f6::10) 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_|AS8PR04MB7558:EE_ X-MS-Office365-Filtering-Correlation-Id: 43abe8bb-7fc1-46bc-ab20-08db87f52573 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: Fl1tUCSK3pMZBMfD5YQWZ0nuQjld1eS4oSFBwxGsXIxQf0nunZXt83adyt1IA4tPeKMQFmY1dJm0LjGh8d4FDEfR5Jx536yRzNlAqiJmnAbwgwT25db7qWJo08/5j1yV6+9ER7G4MN88fYQ6JfCPbN0d60mZvbkxXs6UgMGdD1WFQx20720yXsh+sScn0rzbEnPGSys3Czg5RBk7lgCS8JRC37Gfrwggww78Z12qJeTNlDZlDkGSwSPePdEO8xYLXEhiMA1Q1w6qKNLXMrNkcONP1bVxfVze5XMPEJzIhJNXQQPMGdUxRDNRlRy/ypfpkJOLU81QsLnC7CV6CYEIm+QSX4XrmvNZF1ypA3a7pW0+jHbmkQKdkPPqHZgOe6VV4EeJScUnoNH0mMcD5h2d3xOyGVxI82GzPAAXkE65SI9JmyjZFS8fcfILChY8UQoQRqpRkxfrEhwigg/zgSfJMZAmIcuO6h6wAUwb0pjyl7qcVhOucWuFjxhX9dr5MjuUWbKnYl8l+MnLIkBMs6OSuLgoZrmcLCEqNP8xccZvojVQrmLKvDxEQOoa02HSCvL5RNdIsA+gSNz4YL8NQn5JYPBud96AqZHVHoveWryb75aAWO9hgUfV9NobRfNg6Xzp 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)(346002)(136003)(366004)(376002)(396003)(39860400002)(451199021)(1076003)(478600001)(6666004)(52116002)(6486002)(83380400001)(6506007)(26005)(6512007)(186003)(2906002)(8936002)(41300700001)(66946007)(4326008)(66556008)(8676002)(316002)(5660300002)(38100700002)(38350700002)(66476007)(86362001)(2616005); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 9B10e5tbKGTQTZmpJDo9G9DXjWIwDsVAC+gxxnZhFSR1mJsrKXh8a0BLCxM3m5+NpG2EJ2jxmUyDq82E7Yf2ESh13A3wIBw15Ac8odMEV7+/Wugop8aNaSt2jjdHbLffCK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XJcYM/BFHhCuWM29UlCS1y7z3etEOg+V3xTlLwcCAMIZbnt0Ec5KvzboPRq39iFkn1nM/BBKRApvde0nEVzQ7GEvCwMWjkpYlCFDPHSZn+KQdp2batENtfdoCACLV1+so+R/Tldo8IGuVU6eDUwkrRsIc9GACfkIoN/M2ReZv61vn1jtTMdkLw48GCiPyCfCWjG227ArnqsNkEVImwsB2lFE+cSPjdEVwAmiRiXjK098G4dShqUYvnYXfTRdxITxfZGEYL5Tglvw8o8Szw2JW/DEz5EzatN3Ops5d5DNKaSOSxMQ3wAzjAKRiER8OC0D8afcS/WSFgrvAt399blkyY+oi0o673I+c0A0Y7wp/fM2Jz1PXQMbjhJwGzk258rR6uTZD9HIFxv5X X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 43abe8bb-7fc1-46bc-ab20-08db87f52573 X-MS-Exchange-CrossTenant-AuthSource: DU0PR04MB9417.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Jul 2023 01:11:56.9944 (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: ssBIZlmKjz5Nz90G4rZuQqAjUu5JomSdWrJ37NaPcT7NjvH/LerbSsO/zKg2+NAtorvKenSGIIHiqA+b73c3oQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR04MB7558 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") 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 6fb14e521197..021327fb434f 100644 --- a/drivers/thermal/thermal_of.c +++ b/drivers/thermal/thermal_of.c @@ -298,13 +298,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; @@ -331,13 +331,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;