diff mbox series

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

Message ID 20210210114320.3478-6-andriy.shevchenko@linux.intel.com
State New
Headers show
Series [v1,1/7] ACPI: property: Remove dead code | expand

Commit Message

Andy Shevchenko Feb. 10, 2021, 11:43 a.m. UTC
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@linux.intel.com>
---
 drivers/acpi/property.c | 18 ++++++++++--------
 1 file changed, 10 insertions(+), 8 deletions(-)
diff mbox series

Patch

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;