From patchwork Tue Aug 15 06:26:43 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Zhang Rui X-Patchwork-Id: 9900969 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id A5E3D6028A for ; Tue, 15 Aug 2017 06:27:31 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 96DD428765 for ; Tue, 15 Aug 2017 06:27:31 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8B35728793; Tue, 15 Aug 2017 06:27:31 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F344B28765 for ; Tue, 15 Aug 2017 06:27:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752407AbdHOG0x (ORCPT ); Tue, 15 Aug 2017 02:26:53 -0400 Received: from mga14.intel.com ([192.55.52.115]:7400 "EHLO mga14.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751666AbdHOG0w (ORCPT ); Tue, 15 Aug 2017 02:26:52 -0400 Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga103.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 14 Aug 2017 23:26:51 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.41,376,1498546800"; d="scan'208";a="300199129" Received: from snehakum-mobl2.gar.corp.intel.com ([10.249.69.235]) by fmsmga004.fm.intel.com with ESMTP; 14 Aug 2017 23:26:48 -0700 Message-ID: <1502778403.2591.3.camel@intel.com> Subject: Re: [PATCH] thermal: ti-soc-thermal: Potential error pointer dereferences From: Zhang Rui To: Dan Carpenter Cc: Eduardo Valentin , Keerthy , linux-pm@vger.kernel.org, linux-omap@vger.kernel.org, kernel-janitors@vger.kernel.org Date: Tue, 15 Aug 2017 14:26:43 +0800 In-Reply-To: <20170811075510.cnaisfliycev43w4@mwanda> References: <20170710072422.rs25i5oawmiaofrp@mwanda> <1502416833.2598.3.camel@intel.com> <20170811075510.cnaisfliycev43w4@mwanda> X-Mailer: Evolution 3.18.5.2-0ubuntu3 Mime-Version: 1.0 Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP On Fri, 2017-08-11 at 10:55 +0300, Dan Carpenter wrote: > On Fri, Aug 11, 2017 at 10:00:33AM +0800, Zhang Rui wrote: > > > > On Mon, 2017-07-10 at 10:24 +0300, Dan Carpenter wrote: > > > > > > ti_bandgap_get_sensor_data() can return error pointers so we > > > should > > > check for that.  There is no need to check "data->ti_thermal" for > > > NULL > > > and we removed that from the other cleanup function so we may as > > > well > > > from it in ti_thermal_remove_sensor() to be consistent. > > > > > > Signed-off-by: Dan Carpenter > > > > > > diff --git a/drivers/thermal/ti-soc-thermal/ti-thermal-common.c > > > b/drivers/thermal/ti-soc-thermal/ti-thermal-common.c > > > index c211a8e4a210..9fea354ca90c 100644 > > > --- a/drivers/thermal/ti-soc-thermal/ti-thermal-common.c > > > +++ b/drivers/thermal/ti-soc-thermal/ti-thermal-common.c > > > @@ -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 (data && !IS_ERR(data)) { > > what about > > if (!IS_ERR_OR_NULL(data)) > > > Duh.  Of course, let me resend. that's okay, patch has been updated and applied. From 474b6dbed714ff5786a0d4ae084717bb75bc7169 Mon Sep 17 00:00:00 2001 From: Dan Carpenter Date: Mon, 10 Jul 2017 10:24:23 +0300 Subject: [PATCH] thermal: ti-soc-thermal: Potential error pointer dereferences ti_bandgap_get_sensor_data() can return error pointers so we should check for that.  There is no need to check "data->ti_thermal" for NULL and we removed that from the other cleanup function so we may as well from it in ti_thermal_remove_sensor() to be consistent. Signed-off-by: Dan Carpenter Signed-off-by: Zhang Rui ---  drivers/thermal/ti-soc-thermal/ti-thermal-common.c | 4 ++--  1 file changed, 2 insertions(+), 2 deletions(-) --  2.7.4 -- To unsubscribe from this list: send the line "unsubscribe linux-omap" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/thermal/ti-soc-thermal/ti-thermal-common.c b/drivers/thermal/ti-soc-thermal/ti-thermal-common.c index c211a8e..92b3207 100644 --- a/drivers/thermal/ti-soc-thermal/ti-thermal-common.c +++ b/drivers/thermal/ti-soc-thermal/ti-thermal-common.c @@ -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)) {   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);   }