From patchwork Tue Jun 23 19:52:30 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg Kroah-Hartman X-Patchwork-Id: 223073 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.0 required=3.0 tests=DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable 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 ED691C433E0 for ; Tue, 23 Jun 2020 21:39:25 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id BFEF4206E2 for ; Tue, 23 Jun 2020 21:39:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1592948365; bh=T+rGk9RKgviyHEvJnT1d21Zz2X+wqeEWgR9AJEDewr0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=mTtC+SwhAayVQRGDYjEwlr6R/gYFqkjQJ53hY9EQWvFGFuu6Kn8Xoj0ZyIzn1/LMl /7Hcvzj26Vy+PNZDr9TSLqizWXdGdiHUw0L3Hw8ieA34/IWPMAWcMjxejpiSa9nAQo twS2a7b1qIT2IvY+iZMXy2MMs/5nDc22fZ3pSaeU= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388584AbgFWUHQ (ORCPT ); Tue, 23 Jun 2020 16:07:16 -0400 Received: from mail.kernel.org ([198.145.29.99]:47718 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388564AbgFWUHP (ORCPT ); Tue, 23 Jun 2020 16:07:15 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id E837B2064B; Tue, 23 Jun 2020 20:07:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1592942834; bh=T+rGk9RKgviyHEvJnT1d21Zz2X+wqeEWgR9AJEDewr0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=inE1CD1yzKcJqKmOc0vPu4dfwaaSDzATzFRxrGsVLFJWIl0yb091RGSETPhY3eW5j 8kgu3Lb/sdHFOY4UMUFRiXeXWp50vwPSrPgMNMehj93ytO/Nv1I2cKr/0Vykj76BoQ HoQOr+whjES34ipE4H31zIMBbXIMQ+WsBhZotI2U= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Sudip Mukherjee , Amit Kucheria , Daniel Lezcano , Sasha Levin Subject: [PATCH 5.7 153/477] thermal/drivers/ti-soc-thermal: Avoid dereferencing ERR_PTR Date: Tue, 23 Jun 2020 21:52:30 +0200 Message-Id: <20200623195414.829037889@linuxfoundation.org> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200623195407.572062007@linuxfoundation.org> References: <20200623195407.572062007@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@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 d3e959d01606c..85776db4bf346 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);