[PATCH v1 6/7] ACPI: property: Allow to validate a single value

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



acpi_data_prop_read_single() doesn't accept a NULL parameter for
the value. Let's modify it to accept NULL pointer in order to validate
the single value. This will be needed for the further changes.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@xxxxxxxxxxxxxxx>
---
 drivers/acpi/property.c | 18 ++++++++++--------
 1 file changed, 10 insertions(+), 8 deletions(-)

diff --git a/drivers/acpi/property.c b/drivers/acpi/property.c
index f2386ef32ff1..236316ee0e25 100644
--- a/drivers/acpi/property.c
+++ b/drivers/acpi/property.c
@@ -787,9 +787,6 @@ static int acpi_data_prop_read_single(const struct acpi_device_data *data,
 	const union acpi_object *obj;
 	int ret = 0;
 
-	if (!val)
-		return -EINVAL;
-
 	if (proptype >= DEV_PROP_U8 && proptype <= DEV_PROP_U64)
 		ret = acpi_data_get_property(data, propname, ACPI_TYPE_INTEGER, &obj);
 	else if (proptype == DEV_PROP_STRING)
@@ -801,23 +798,28 @@ static int acpi_data_prop_read_single(const struct acpi_device_data *data,
 	case DEV_PROP_U8:
 		if (obj->integer.value > U8_MAX)
 			return -EOVERFLOW;
-		*(u8 *)val = obj->integer.value;
+		if (val)
+			*(u8 *)val = obj->integer.value;
 		break;
 	case DEV_PROP_U16:
 		if (obj->integer.value > U16_MAX)
 			return -EOVERFLOW;
-		*(u16 *)val = obj->integer.value;
+		if (val)
+			*(u16 *)val = obj->integer.value;
 		break;
 	case DEV_PROP_U32:
 		if (obj->integer.value > U32_MAX)
 			return -EOVERFLOW;
-		*(u32 *)val = obj->integer.value;
+		if (val)
+			*(u32 *)val = obj->integer.value;
 		break;
 	case DEV_PROP_U64:
-		*(u64 *)val = obj->integer.value;
+		if (val)
+			*(u64 *)val = obj->integer.value;
 		break;
 	case DEV_PROP_STRING:
-		*(char **)val = obj->string.pointer;
+		if (val)
+			*(char **)val = obj->string.pointer;
 		return 1;
 	default:
 		return -EINVAL;
-- 
2.30.0




[Index of Archives]     [Linux IBM ACPI]     [Linux Power Management]     [Linux Kernel]     [Linux Laptop]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Device Mapper]     [Linux Resources]

  Powered by Linux