* [PATCH] thermal: ti-soc-thermal: Potential error pointer dereferences @ 2017-07-10 7:24 Dan Carpenter 2017-08-11 2:00 ` Zhang Rui 0 siblings, 1 reply; 4+ messages in thread From: Dan Carpenter @ 2017-07-10 7:24 UTC (permalink / raw) To: Eduardo Valentin Cc: Keerthy, Zhang Rui, linux-pm, linux-omap, kernel-janitors 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 <dan.carpenter@oracle.com> 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)) { 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 (data && !IS_ERR(data)) { cpufreq_cooling_unregister(data->cool_dev); cpufreq_cpu_put(data->policy); } ^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] thermal: ti-soc-thermal: Potential error pointer dereferences 2017-07-10 7:24 [PATCH] thermal: ti-soc-thermal: Potential error pointer dereferences Dan Carpenter @ 2017-08-11 2:00 ` Zhang Rui 2017-08-11 7:55 ` Dan Carpenter 0 siblings, 1 reply; 4+ messages in thread From: Zhang Rui @ 2017-08-11 2:00 UTC (permalink / raw) To: Dan Carpenter, Eduardo Valentin Cc: Keerthy, linux-pm, linux-omap, kernel-janitors 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 <dan.carpenter@oracle.com> > > 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)) thanks, rui > 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 (data && !IS_ERR(data)) { > cpufreq_cooling_unregister(data->cool_dev); > cpufreq_cpu_put(data->policy); > } ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] thermal: ti-soc-thermal: Potential error pointer dereferences 2017-08-11 2:00 ` Zhang Rui @ 2017-08-11 7:55 ` Dan Carpenter 2017-08-15 6:26 ` Zhang Rui 0 siblings, 1 reply; 4+ messages in thread From: Dan Carpenter @ 2017-08-11 7:55 UTC (permalink / raw) To: Zhang Rui Cc: Eduardo Valentin, Keerthy, linux-pm, linux-omap, kernel-janitors 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 <dan.carpenter@oracle.com> > > > > 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. regards, dan carpenter ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] thermal: ti-soc-thermal: Potential error pointer dereferences 2017-08-11 7:55 ` Dan Carpenter @ 2017-08-15 6:26 ` Zhang Rui 0 siblings, 0 replies; 4+ messages in thread From: Zhang Rui @ 2017-08-15 6:26 UTC (permalink / raw) To: Dan Carpenter Cc: Eduardo Valentin, Keerthy, linux-pm, linux-omap, kernel-janitors 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 <dan.carpenter@oracle.com> > > > > > > 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 <dan.carpenter@oracle.com> 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 <dan.carpenter@oracle.com> Signed-off-by: Zhang Rui <rui.zhang@intel.com> --- drivers/thermal/ti-soc-thermal/ti-thermal-common.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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); } -- 2.7.4 ^ permalink raw reply related [flat|nested] 4+ messages in thread
end of thread, other threads:[~2017-08-15 6:26 UTC | newest] Thread overview: 4+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2017-07-10 7:24 [PATCH] thermal: ti-soc-thermal: Potential error pointer dereferences Dan Carpenter 2017-08-11 2:00 ` Zhang Rui 2017-08-11 7:55 ` Dan Carpenter 2017-08-15 6:26 ` Zhang Rui
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).