Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp10722ybt; Tue, 23 Jun 2020 13:57:00 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwf7PcpvO51m9S8VHKn9KHICEpO7ryydEidBLT9qM8NBwluQpjr+JfuI/M+fM/X0nibRLS+ X-Received: by 2002:a17:906:848b:: with SMTP id m11mr6102296ejx.10.1592945819946; Tue, 23 Jun 2020 13:56:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1592945819; cv=none; d=google.com; s=arc-20160816; b=y74nK3b7kr9qVsODDAjHRh+1p2HrrToKNq2FcxDXeJ4xnoNAjhN6eIlhCLvTjuoUA+ SLZF7jFlrQXwUNpqmpBbBQ0758QTg/xCAg8Qq6WwPD6BWMY8b9mmHwmSCOMETA/zE2sR /hvEim0kmVBH56uDnVCXIISo8KhOgIDCrpcm43hS3ozSL+DjMCup2Aq0XPvDslAiTbq2 brHksEHAWuPFAxfaIdSIN1IFfao6iFQtoKGqgBy+/4oNhomI/teANN6DYhZPHuSxziTf tGlTjLZZB7Zes+jQ6WM6TAim1C+VaBb3Y3tG9fZJQV+AW2IhgEUgUI3nQqSLRYkA4NXB WfRw== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=EmlCXu1Jvj38gnIM67u/DP5nvH6Ng43kPRg34KCcr0s=; b=bZX4EK9oRgCNiwzpqP5ajp4lBmJ0DOfCDDUYi4lYF3MvB85e967dGaX4MxX4dgeyOG Nd9+Kb9fKHctYh2tWTvnigJIfRIjABBFhqr36SJ5PeKjIfvpOtX2NBhrSFjm41QG6+0x PDn3TH+RI/kZ+PDAqXEXRu2FHek5MsLX3NHlEhCnM+/63+2id1BTxh+cnxu+5g7UEdsG aq9BsmDXp16VRSdrBQObiM6oKBJFmoewM7f/EG+3Gkpt22i9YH+30uTkTgZoUygc5MZn yJdmoHSxT6ec5kY93d7XnsnOVOrCBOyj8zhiKOQfAZQ+026LI8Osud9ZWlC5tSe/UetW +eXg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Fvpa7Nyg; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id m27si3528644eja.699.2020.06.23.13.56.35; Tue, 23 Jun 2020 13:56:59 -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=Fvpa7Nyg; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390755AbgFWUzX (ORCPT + 99 others); Tue, 23 Jun 2020 16:55:23 -0400 Received: from mail.kernel.org ([198.145.29.99]:42416 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2392715AbgFWUpF (ORCPT ); Tue, 23 Jun 2020 16:45:05 -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 CB7CB21BE5; Tue, 23 Jun 2020 20:45:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1592945105; bh=UZAS9JmDAz7kGwfXP+WflYdOOxq7xdo2yFVAB6HGzOE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Fvpa7NygYG5M18+a5BVJQ4BtDGDnn74X4kf9p0p4ISOf08DhrbxidD1ZDVPYlEXNo eIs9NXoV/fs+7NyA3Jjg9Oi7Lpr2v7DJ19RHzyEzSxlx+SDDG+tZQmbS8mx5hpUXLR NGWCWJNw9zfncNGXbLPNsewBG7Kaqu+y2S4eJdLg= 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 4.14 042/136] thermal/drivers/ti-soc-thermal: Avoid dereferencing ERR_PTR Date: Tue, 23 Jun 2020 21:58:18 +0200 Message-Id: <20200623195305.762445318@linuxfoundation.org> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200623195303.601828702@linuxfoundation.org> References: <20200623195303.601828702@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 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 c211a8e4a2105..fa98c398d70f3 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