lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20210210114320.3478-7-andriy.shevchenko@linux.intel.com>
Date:   Wed, 10 Feb 2021 13:43:20 +0200
From:   Andy Shevchenko <andriy.shevchenko@...ux.intel.com>
To:     linux-acpi@...r.kernel.org, linux-kernel@...r.kernel.org
Cc:     "Rafael J. Wysocki" <rjw@...ysocki.net>,
        Len Brown <lenb@...nel.org>,
        Andy Shevchenko <andriy.shevchenko@...ux.intel.com>,
        Calvin Johnson <calvin.johnson@....nxp.com>
Subject: [PATCH v1 7/7] ACPI: property: Allow counting a single value as an array of 1 element

We allow to read the single value as a first element in the array.
Unfortunately the counting doesn't work in this case and we can't
call fwnode_property_count_*() API without getting an error.

Modify acpi_data_prop_read() to always try the single value read
and thus allow counting the single value as an array of 1 element.

Reported-by: Calvin Johnson <calvin.johnson@....nxp.com>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@...ux.intel.com>
---
 drivers/acpi/property.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/acpi/property.c b/drivers/acpi/property.c
index 236316ee0e25..d6100585fceb 100644
--- a/drivers/acpi/property.c
+++ b/drivers/acpi/property.c
@@ -913,12 +913,14 @@ static int acpi_data_prop_read(const struct acpi_device_data *data,
 	const union acpi_object *items;
 	int ret;
 
-	if (val && nval == 1) {
+	/* Try to read as a single value first */
+	if (!val || nval == 1) {
 		ret = acpi_data_prop_read_single(data, propname, proptype, val);
 		if (ret >= 0)
-			return ret;
+			return val ? ret : 1;
 	}
 
+	/* It's not the single value, get an array instead */
 	ret = acpi_data_get_property_array(data, propname, ACPI_TYPE_ANY, &obj);
 	if (ret)
 		return ret;
-- 
2.30.0

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ