From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-10.1 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B8368C433E0 for ; Thu, 18 Jun 2020 01:51:39 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7F042221F0 for ; Thu, 18 Jun 2020 01:51:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1592445099; bh=1vNCKVBDL3uGljQY3US1t2T4+3QsHCABbxYqhgu8NQw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=AduDy4K0N4m5vox/PKoxaUhcfOpCzP89fhegxwSVkgBgraltUz28fyyJdhRfmwbk5 9jYnzMkGNi8b5NoFiTb5tdEKRNzm/HnUOHwcd/ou0zvyFfeohKxUP3ALUJlP+R55bo sIFyS6xyutWpWzVZ0cV99ebxiVdJV/ccijHwydOA= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729791AbgFRBvh (ORCPT ); Wed, 17 Jun 2020 21:51:37 -0400 Received: from mail.kernel.org ([198.145.29.99]:34730 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727071AbgFRB06 (ORCPT ); Wed, 17 Jun 2020 21:26:58 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 0FB7921D80; Thu, 18 Jun 2020 01:26:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1592443617; bh=1vNCKVBDL3uGljQY3US1t2T4+3QsHCABbxYqhgu8NQw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=J+HJx6Krzg6BMoqJQ183PlOHciWdIjlGjH2rrwQEO6KnFOQj1Fp0sfOtT0JbT+fST iI9Locv5CJpxNotN+miy83JMru98gTpU+3TzrG/Qg/hdT/rvE4wcr2Ygz3FUH/cOuZ 9MefWmvjYxb7hat5mCukd+jRTNix5V8vNKF5wKdw= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Sudip Mukherjee , Amit Kucheria , Daniel Lezcano , Sasha Levin , linux-pm@vger.kernel.org, linux-omap@vger.kernel.org Subject: [PATCH AUTOSEL 4.14 044/108] thermal/drivers/ti-soc-thermal: Avoid dereferencing ERR_PTR Date: Wed, 17 Jun 2020 21:24:56 -0400 Message-Id: <20200618012600.608744-44-sashal@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200618012600.608744-1-sashal@kernel.org> References: <20200618012600.608744-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org From: Sudip Mukherjee [ Upstream commit 7440f518dad9d861d76c64956641eeddd3586f75 ] On error the function ti_bandgap_get_sensor_data() returns the error code in ERR_PTR() but we only checked if the return value is NULL or not. And, so we can dereference an error code inside ERR_PTR. While at it, convert a check to IS_ERR_OR_NULL. Signed-off-by: Sudip Mukherjee Reviewed-by: Amit Kucheria Signed-off-by: Daniel Lezcano Link: https://lore.kernel.org/r/20200424161944.6044-1-sudipm.mukherjee@gmail.com Signed-off-by: Sasha Levin --- drivers/thermal/ti-soc-thermal/ti-thermal-common.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/thermal/ti-soc-thermal/ti-thermal-common.c b/drivers/thermal/ti-soc-thermal/ti-thermal-common.c index c211a8e4a210..fa98c398d70f 100644 --- a/drivers/thermal/ti-soc-thermal/ti-thermal-common.c +++ b/drivers/thermal/ti-soc-thermal/ti-thermal-common.c @@ -183,7 +183,7 @@ int ti_thermal_expose_sensor(struct ti_bandgap *bgp, int id, data = ti_bandgap_get_sensor_data(bgp, id); - if (!data || IS_ERR(data)) + if (!IS_ERR_OR_NULL(data)) data = ti_thermal_build_data(bgp, id); if (!data) @@ -210,7 +210,7 @@ int ti_thermal_remove_sensor(struct ti_bandgap *bgp, int id) data = ti_bandgap_get_sensor_data(bgp, id); - if (data && data->ti_thermal) { + if (!IS_ERR_OR_NULL(data) && data->ti_thermal) { if (data->our_zone) thermal_zone_device_unregister(data->ti_thermal); } @@ -276,7 +276,7 @@ int ti_thermal_unregister_cpu_cooling(struct ti_bandgap *bgp, int id) data = ti_bandgap_get_sensor_data(bgp, id); - if (data) { + if (!IS_ERR_OR_NULL(data)) { cpufreq_cooling_unregister(data->cool_dev); cpufreq_cpu_put(data->policy); } -- 2.25.1