Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1275297 > unrolled thread

[PATCH] thermal: ti-soc-thermal: fix error check

Started bySudip Mukherjee <sudipm.mukherjee@gmail.com>
First post2015-11-23 14:00 +0100
Last post2015-11-24 08:50 +0100
Articles 3 — 2 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH] thermal: ti-soc-thermal: fix error check Sudip Mukherjee <sudipm.mukherjee@gmail.com> - 2015-11-23 14:00 +0100
    Re: [PATCH] thermal: ti-soc-thermal: fix error check Eduardo Valentin <edubezval@gmail.com> - 2015-11-24 00:30 +0100
      Re: [PATCH] thermal: ti-soc-thermal: fix error check Sudip Mukherjee <sudipm.mukherjee@gmail.com> - 2015-11-24 08:50 +0100

#1275297 — [PATCH] thermal: ti-soc-thermal: fix error check

FromSudip Mukherjee <sudipm.mukherjee@gmail.com>
Date2015-11-23 14:00 +0100
Subject[PATCH] thermal: ti-soc-thermal: fix error check
Message-ID<qxYSS-1QC-15@gated-at.bofh.it>
We were only checking if data is not NULL but
ti_bandgap_get_sensor_data() can return NULL or ERR_PTR.

Signed-off-by: Sudip Mukherjee <sudip@vectorindia.org>
---
 drivers/thermal/ti-soc-thermal/ti-thermal-common.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/thermal/ti-soc-thermal/ti-thermal-common.c b/drivers/thermal/ti-soc-thermal/ti-thermal-common.c
index b213a12..d76bb7c 100644
--- a/drivers/thermal/ti-soc-thermal/ti-thermal-common.c
+++ b/drivers/thermal/ti-soc-thermal/ti-thermal-common.c
@@ -365,7 +365,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);
 		else
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [next] | [standalone]


#1275960

FromEduardo Valentin <edubezval@gmail.com>
Date2015-11-24 00:30 +0100
Message-ID<qy8Iy-6V-3@gated-at.bofh.it>
In reply to#1275297
On Mon, Nov 23, 2015 at 06:24:41PM +0530, Sudip Mukherjee wrote:
> We were only checking if data is not NULL but
> ti_bandgap_get_sensor_data() can return NULL or ERR_PTR.

Do you have a fail case? Can you please send the logs too?

> 
> Signed-off-by: Sudip Mukherjee <sudip@vectorindia.org>
> ---
>  drivers/thermal/ti-soc-thermal/ti-thermal-common.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/thermal/ti-soc-thermal/ti-thermal-common.c b/drivers/thermal/ti-soc-thermal/ti-thermal-common.c
> index b213a12..d76bb7c 100644
> --- a/drivers/thermal/ti-soc-thermal/ti-thermal-common.c
> +++ b/drivers/thermal/ti-soc-thermal/ti-thermal-common.c
> @@ -365,7 +365,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) {

I don t really see the need for this as we always
ti_bandgap_set_sensor_data with a valid pointer, never with a ERR PTR.
So, it would be either valid or NULL.

>  		if (data->our_zone)
>  			thermal_zone_device_unregister(data->ti_thermal);
>  		else
> -- 
> 1.9.1
> 
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1276113

FromSudip Mukherjee <sudipm.mukherjee@gmail.com>
Date2015-11-24 08:50 +0100
Message-ID<qygwq-58x-1@gated-at.bofh.it>
In reply to#1275960
On Mon, Nov 23, 2015 at 03:25:43PM -0800, Eduardo Valentin wrote:
> On Mon, Nov 23, 2015 at 06:24:41PM +0530, Sudip Mukherjee wrote:
> > We were only checking if data is not NULL but
> > ti_bandgap_get_sensor_data() can return NULL or ERR_PTR.
> 
> Do you have a fail case? Can you please send the logs too?
> 
> > 
> > Signed-off-by: Sudip Mukherjee <sudip@vectorindia.org>
> > ---
> >  drivers/thermal/ti-soc-thermal/ti-thermal-common.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/drivers/thermal/ti-soc-thermal/ti-thermal-common.c b/drivers/thermal/ti-soc-thermal/ti-thermal-common.c
> > index b213a12..d76bb7c 100644
> > --- a/drivers/thermal/ti-soc-thermal/ti-thermal-common.c
> > +++ b/drivers/thermal/ti-soc-thermal/ti-thermal-common.c
> > @@ -365,7 +365,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) {
> 
> I don t really see the need for this as we always
> ti_bandgap_set_sensor_data with a valid pointer, never with a ERR PTR.
> So, it would be either valid or NULL.

ERR_PTR is not coming from ti_bandgap_set_sensor_data(). In
ti_bandgap_get_sensor_data() if ti_bandgap_validate() fails then it
returns ERR_PTR(ret). So just by checking for NULL we are not checking
for any error return from ti_bandgap_validate().

regards
sudip	
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web