diff mbox

[RESEND] thermal: helpers: Check return value of get_temp

Message ID 1465232019-12441-1-git-send-email-rklein@nvidia.com (mailing list archive)
State Accepted, archived
Delegated to: Zhang Rui
Headers show

Commit Message

Rhyland Klein June 6, 2016, 4:53 p.m. UTC
Check the return value of get_temp, which can fail. If it does, then
unlock and return the error code.

Signed-off-by: Rhyland Klein <rklein@nvidia.com>
---
 drivers/thermal/thermal_helpers.c | 4 ++++
 1 file changed, 4 insertions(+)

Comments

Rhyland Klein June 23, 2016, 5:40 p.m. UTC | #1
On 6/6/2016 12:53 PM, Rhyland Klein wrote:
> Check the return value of get_temp, which can fail. If it does, then
> unlock and return the error code.
> 
> Signed-off-by: Rhyland Klein <rklein@nvidia.com>
> ---
>  drivers/thermal/thermal_helpers.c | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/drivers/thermal/thermal_helpers.c b/drivers/thermal/thermal_helpers.c
> index 5e1c160944c9..dc260749f8d6 100644
> --- a/drivers/thermal/thermal_helpers.c
> +++ b/drivers/thermal/thermal_helpers.c
> @@ -90,6 +90,10 @@ int thermal_zone_get_temp(struct thermal_zone_device *tz, int *temp)
>  	mutex_lock(&tz->lock);
>  
>  	ret = tz->ops->get_temp(tz, temp);
> +	if (!ret) {
> +		mutex_unlock(&tz->lock);
> +		goto exit;
> +	}
>  
>  	if (IS_ENABLED(CONFIG_THERMAL_EMULATION) && tz->emul_temperature) {
>  		for (count = 0; count < tz->trips; count++) {
> 

I haven't seen any comments on this. Has anyone had a chance to take a
look at it yet?

-rhyland
Rhyland Klein July 5, 2016, 4:22 p.m. UTC | #2
On 6/6/2016 12:53 PM, Rhyland Klein wrote:
> Check the return value of get_temp, which can fail. If it does, then
> unlock and return the error code.
> 
> Signed-off-by: Rhyland Klein <rklein@nvidia.com>
> ---
>  drivers/thermal/thermal_helpers.c | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/drivers/thermal/thermal_helpers.c b/drivers/thermal/thermal_helpers.c
> index 5e1c160944c9..dc260749f8d6 100644
> --- a/drivers/thermal/thermal_helpers.c
> +++ b/drivers/thermal/thermal_helpers.c
> @@ -90,6 +90,10 @@ int thermal_zone_get_temp(struct thermal_zone_device *tz, int *temp)
>  	mutex_lock(&tz->lock);
>  
>  	ret = tz->ops->get_temp(tz, temp);
> +	if (!ret) {
> +		mutex_unlock(&tz->lock);
> +		goto exit;
> +	}
>  
>  	if (IS_ENABLED(CONFIG_THERMAL_EMULATION) && tz->emul_temperature) {
>  		for (count = 0; count < tz->trips; count++) {
> 

I haven't seen any comments on this patch, has anyone had a chance to
review it yet?

-rhyland
Zhang Rui July 28, 2016, 8:50 a.m. UTC | #3
On 二, 2016-07-05 at 12:22 -0400, Rhyland Klein wrote:
> On 6/6/2016 12:53 PM, Rhyland Klein wrote:
> > 
> > Check the return value of get_temp, which can fail. If it does,
> > then
> > unlock and return the error code.
> > 
> > Signed-off-by: Rhyland Klein <rklein@nvidia.com>
> > ---
> >  drivers/thermal/thermal_helpers.c | 4 ++++
> >  1 file changed, 4 insertions(+)
> > 
> > diff --git a/drivers/thermal/thermal_helpers.c
> > b/drivers/thermal/thermal_helpers.c
> > index 5e1c160944c9..dc260749f8d6 100644
> > --- a/drivers/thermal/thermal_helpers.c
> > +++ b/drivers/thermal/thermal_helpers.c
> > @@ -90,6 +90,10 @@ int thermal_zone_get_temp(struct
> > thermal_zone_device *tz, int *temp)
> >  	mutex_lock(&tz->lock);
> >  
> >  	ret = tz->ops->get_temp(tz, temp);
> > +	if (!ret) {
> > +		mutex_unlock(&tz->lock);
> > +		goto exit;
> > +	}
> >  
> >  	if (IS_ENABLED(CONFIG_THERMAL_EMULATION) && tz-
> > >emul_temperature) {
> >  		for (count = 0; count < tz->trips; count++) {
> > 
> I haven't seen any comments on this patch, has anyone had a chance to
> review it yet?

Patch applied, it would be merged together with the thermal reorg
patches.

thanks,
rui
--
To unsubscribe from this list: send the line "unsubscribe linux-pm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/drivers/thermal/thermal_helpers.c b/drivers/thermal/thermal_helpers.c
index 5e1c160944c9..dc260749f8d6 100644
--- a/drivers/thermal/thermal_helpers.c
+++ b/drivers/thermal/thermal_helpers.c
@@ -90,6 +90,10 @@  int thermal_zone_get_temp(struct thermal_zone_device *tz, int *temp)
 	mutex_lock(&tz->lock);
 
 	ret = tz->ops->get_temp(tz, temp);
+	if (!ret) {
+		mutex_unlock(&tz->lock);
+		goto exit;
+	}
 
 	if (IS_ENABLED(CONFIG_THERMAL_EMULATION) && tz->emul_temperature) {
 		for (count = 0; count < tz->trips; count++) {