Patchworkβ acpi_power_meter: Don't leak ACPI error codes to userspace

login
register
about
Submitter Darrick J. Wong
Date 2009-10-22 01:01:37
Message ID <20091022010137.GB21723@tux1.beaverton.ibm.com>
Download mbox | patch
Permalink /patch/55238/
State New
Headers show

Comments

Darrick J. Wong - 2009-10-22 01:01:37
acpi-power-meter: Don't leak ACPI error codes to userspace

If the ACPI methods return an error code, we must return -EINVAL to userspace
to flag the error.  Right now we pass the (positive) number right through,
which causes echo to keep writing bogus values.

Signed-off-by: Darrick J. Wong <djwong@us.ibm.com>
---

 drivers/acpi/power_meter.c |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)


--
To unsubscribe from this list: send the line "unsubscribe linux-acpi" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Jean Delvare - 2009-10-22 07:27:53
On Wed, 21 Oct 2009 18:01:37 -0700, Darrick J. Wong wrote:
> acpi-power-meter: Don't leak ACPI error codes to userspace
> 
> If the ACPI methods return an error code, we must return -EINVAL to userspace
> to flag the error.  Right now we pass the (positive) number right through,
> which causes echo to keep writing bogus values.
> 
> Signed-off-by: Darrick J. Wong <djwong@us.ibm.com>

Acked-by: Jean Delvare <khali@linux-fr.org>

> ---
> 
>  drivers/acpi/power_meter.c |    6 +++++-
>  1 files changed, 5 insertions(+), 1 deletions(-)
> 
> 
> diff --git a/drivers/acpi/power_meter.c b/drivers/acpi/power_meter.c
> index e6bfd77..2ef7030 100644
> --- a/drivers/acpi/power_meter.c
> +++ b/drivers/acpi/power_meter.c
> @@ -294,7 +294,11 @@ static int set_acpi_trip(struct acpi_power_meter_resource *resource)
>  		return -EINVAL;
>  	}
>  
> -	return data;
> +	/* _PTP returns 0 on success, nonzero otherwise */
> +	if (data)
> +		return -EINVAL;
> +
> +	return 0;
>  }
>  
>  static ssize_t set_trip(struct device *dev, struct device_attribute *devattr,
Len Brown - 2009-11-05 17:25:53
applied

thanks,
Len Brown, Intel Open Source Technology Center

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

Patch

diff --git a/drivers/acpi/power_meter.c b/drivers/acpi/power_meter.c
index e6bfd77..2ef7030 100644
--- a/drivers/acpi/power_meter.c
+++ b/drivers/acpi/power_meter.c
@@ -294,7 +294,11 @@  static int set_acpi_trip(struct acpi_power_meter_resource *resource)
 		return -EINVAL;
 	}
 
-	return data;
+	/* _PTP returns 0 on success, nonzero otherwise */
+	if (data)
+		return -EINVAL;
+
+	return 0;
 }
 
 static ssize_t set_trip(struct device *dev, struct device_attribute *devattr,