Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp978842ybt; Wed, 17 Jun 2020 19:45:37 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw/rufnLj3EoWJZbJLDZhD6c1YmoOVESsRhsMuWx3RBjrYQs8En054u5hrvPfMxAtQIFf4e X-Received: by 2002:a17:906:c1c4:: with SMTP id bw4mr1949456ejb.452.1592448337475; Wed, 17 Jun 2020 19:45:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1592448337; cv=none; d=google.com; s=arc-20160816; b=LE4MnyN/+ciPgpIyi/BVShED0vdVP6Rco6GOAMS87Wm97y+9TI6JbsZVJc3JMy0RYx 62U/byKgkocGni2ysUs3ie6ilQ/Fdnp2c0EC7oG6XTJ7D75J5hx/uD01SXe7/x0aRF/q L9DFvQb3fNd5vpmDsvNvOlG9VZfRu8IiRZHlPMUuZG38E0AmADQ/Q+FdttrnNPkDBkz5 e2iCueOq/1SwnI48+fwY8Oc7xo4e6N+AEa/DcdiCt7bnT9S/M9BuvgYQJEgwpa509+eX ePZ8QZlUnwm5ziFuVQ9BuiYVqvqrvB++TV4xnIQMsDlpFL2XQ4bPJ1gOIdM6/e0/Ru8I yWXg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=2bClAJZh76ZZnG7PeZSddxfo0Lza8uM2UMt9HVggqjU=; b=gUK8YHVgROQfuPUxWS/lbtP6WZiSI3Hmvf1KFwStAhSPTtH1cTVI/Zfi3au8QPFnS2 fOpLQGe9nJvL2ZKIjOZ7Ft1m6FAZLVbxxznvSB4kBf825IVXC/3VuVJyVBQDd3Se6rys aWqox7LQLEjZaKB/5cQe3Y9nsRIfqU6pac3sPb7IjPxatABvKHPbtCPHzowrU/kIJlo7 6QejNUrpIpp1eABbRXJGiV8mgDLWW6+FO7z4VewumuLKowy81NMwZswBUSPUKAsDfjBF TnkBszHhnSSZA+JcrkQ4jSbQNhCuT79nevOz+iB2/ZY+o5Q980zqNLPFWICoJymprA6E 2hMg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=DmldXKW4; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id p17si1074233ejy.722.2020.06.17.19.45.15; Wed, 17 Jun 2020 19:45:37 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=DmldXKW4; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731562AbgFRCnj (ORCPT + 99 others); Wed, 17 Jun 2020 22:43:39 -0400 Received: from mail.kernel.org ([198.145.29.99]:39466 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728113AbgFRBLb (ORCPT ); Wed, 17 Jun 2020 21:11:31 -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 4F89320CC7; Thu, 18 Jun 2020 01:11:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1592442691; bh=EvwO6JCvwjH0ii7c8P2k9TCjFrLWsFBoTY+wiB+vL34=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DmldXKW4DMAMOBkNiM0yLRctZ5uVCSwjTjeF1dz76nsmTlLav5rYuSy9IOb0z41Mg TZ/H+ithTZPvUqiSL6CbFVXC0rkZYoSQDXMtxYezhC2/tzFYB+3DujYICLED2RcCJ6 9h52OqmrVzG7/sC4sZFrn12s116s1KDIF7L4HFuY= 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 5.7 156/388] thermal/drivers/ti-soc-thermal: Avoid dereferencing ERR_PTR Date: Wed, 17 Jun 2020 21:04:13 -0400 Message-Id: <20200618010805.600873-156-sashal@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200618010805.600873-1-sashal@kernel.org> References: <20200618010805.600873-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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 d3e959d01606..85776db4bf34 100644 --- a/drivers/thermal/ti-soc-thermal/ti-thermal-common.c +++ b/drivers/thermal/ti-soc-thermal/ti-thermal-common.c @@ -169,7 +169,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) @@ -196,7 +196,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); } @@ -262,7 +262,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); if (data->policy) cpufreq_cpu_put(data->policy); -- 2.25.1