platform/x86: hp-bioscfg: accept reduced ACPI packages from older HP BIOS

hp_init_bios_package_attribute() hard-fails when a WMI ACPI package
contains fewer elements than the type-specific expected count (e.g. 11
elements instead of 13 for INTEGER or ENUMERATION attributes). This
causes the entire hp_bioscfg driver to skip attribute enumeration on
older HP hardware whose BIOS returns shortened packages when optional
fields like prerequisites or possible values are absent.

Observed on HP EliteBook 840 G2 (BIOS M71 Ver. 01.31):

  hp_bioscfg: ACPI-package does not have enough elements: 11 < 13

The element layout has two tiers:
  - Elements 0-9 (SECURITY_LEVEL+1 = 10): common to all attribute types
  - Elements 10-N: type-specific (bounds, values, encodings, ...)

The per-type populate functions (hp_populate_*_elements_from_package)
already handle sparse packages correctly via their own elem < count
loop guards and inner-loop bounds checks. The only unsafe case is when
we lack even the common elements needed to register the attribute.

Fix by introducing COMMON_ELEM_CNT to mark the hard minimum (10), and
splitting the check into two tiers:
  - Fewer than COMMON_ELEM_CNT elements: hard fail, can't proceed.
  - Fewer than expected type-specific elements: warn, but let the
    populate function parse what is available.

Fixes: a34fc329b1 ("platform/x86: hp-bioscfg: bioscfg")
Cc: stable@vger.kernel.org
Signed-off-by: Muhammad Bilal <meatuni001@gmail.com>
Reviewed-by: Mario Limonciello (AMD) <superm1@kernel.org>
Link: https://patch.msgid.link/20260709165900.30615-4-meatuni001@gmail.com
Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
This commit is contained in:
Muhammad Bilal 2026-07-09 21:58:58 +05:00 committed by Ilpo Järvinen
parent 1d143d7829
commit 40e10e6cc8
No known key found for this signature in database
GPG Key ID: 59AC4F6153E5CE31
2 changed files with 11 additions and 3 deletions

View File

@ -661,12 +661,17 @@ static int hp_init_bios_package_attribute(enum hp_wmi_data_type attr_type,
int ret = 0;
/* Take action appropriate to each ACPI TYPE */
if (obj->package.count < min_elements) {
pr_err("ACPI-package does not have enough elements: %d < %d\n",
obj->package.count, min_elements);
if (obj->package.count < COMMON_ELEM_CNT) {
pr_err("ACPI-package is missing common elements: %d < %d\n",
obj->package.count, COMMON_ELEM_CNT);
goto pack_attr_exit;
}
if (obj->package.count < min_elements) {
pr_warn("ACPI-package has fewer elements than expected: %d < %d, parsing available elements\n",
obj->package.count, min_elements);
}
elements = obj->package.elements;
/* sanity checking */

View File

@ -279,6 +279,9 @@ enum hp_wmi_data_elements {
PSWD_ENCODINGS = 13,
PSWD_IS_SET = 14,
PSWD_ELEM_CNT = 15,
/* Minimum elements shared by all attribute types (NAME..SECURITY_LEVEL) */
COMMON_ELEM_CNT = SECURITY_LEVEL + 1,
};
#define GET_INSTANCE_ID(type) \