From: Artem Maksimov <okuroshioffc@gmail.com>
To: "Jorge Lopez" <jorge.lopez2@hp.com>,
"Hans de Goede" <hansg@kernel.org>,
"Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>
Cc: platform-driver-x86@vger.kernel.org,
linux-kernel@vger.kernel.org,
"Thomas Weißschuh" <linux@weissschuh.net>,
"Artem Maksimov" <okuroshioffc@gmail.com>
Subject: [PATCH] platform/x86: hp-bioscfg: Support allocation bios vars
Date: Fri, 25 Sep 2026 22:44:54 +0300 [thread overview]
Message-ID: <20260925194454.6850-1-okuroshioffc@gmail.com> (raw)
On HP systems with a large number of BIOS
attribute instances, the kzalloc_objs()
allocation in hp_alloc_ordered_list_data() and
hp_alloc_string_data() can fail when physical
memory is fragmented, leaving the driver
unable to register those attributes.
The same failure mode was already fixed for enumeration_data in
hp_alloc_enumeration_data() by commit 916727cfdb72 ("platform/x86:
hp-bioscfg: Support allocations of larger data"), reported on HP
Z2 Tower G9 and Z4 G5 Workstation systems:
https://bugs.debian.org/1127612
order-list-attributes.c and string-attributes.c use
the identical allocation pattern and are still affected.
Apply the same fix: fall back to kvzalloc_objs()/kvfree()
instead of kzalloc_objs()/kfree(), and return -EINVAL
early when the instance count is zero.
Link: https://bugs.debian.org/1127612
Signed-off-by: Artem Maksimov <okuroshioffc@gmail.com>
---
.../x86/hp/hp-bioscfg/order-list-attributes.c | 11 ++++++++---
.../platform/x86/hp/hp-bioscfg/string-attributes.c | 11 ++++++++---
2 files changed, 16 insertions(+), 6 deletions(-)
diff --git a/drivers/platform/x86/hp/hp-bioscfg/order-list-attributes.c b/drivers/platform/x86/hp/hp-bioscfg/order-list-attributes.c
index 5bf8d40bdf81..80ac15435a18 100644
--- a/drivers/platform/x86/hp/hp-bioscfg/order-list-attributes.c
+++ b/drivers/platform/x86/hp/hp-bioscfg/order-list-attributes.c
@@ -98,8 +98,13 @@ int hp_alloc_ordered_list_data(void)
{
bioscfg_drv.ordered_list_instances_count =
hp_get_instance_count(HP_WMI_BIOS_ORDERED_LIST_GUID);
- bioscfg_drv.ordered_list_data = kzalloc_objs(*bioscfg_drv.ordered_list_data,
- bioscfg_drv.ordered_list_instances_count);
+
+ if (!bioscfg_drv.ordered_list_instances_count)
+ return -EINVAL;
+ bioscfg_drv.ordered_list_data =
+ kvzalloc_objs(*bioscfg_drv.ordered_list_data,
+ bioscfg_drv.ordered_list_instances_count);
+
if (!bioscfg_drv.ordered_list_data) {
bioscfg_drv.ordered_list_instances_count = 0;
return -ENOMEM;
@@ -438,6 +443,6 @@ void hp_exit_ordered_list_attributes(void)
}
bioscfg_drv.ordered_list_instances_count = 0;
- kfree(bioscfg_drv.ordered_list_data);
+ kvfree(bioscfg_drv.ordered_list_data);
bioscfg_drv.ordered_list_data = NULL;
}
diff --git a/drivers/platform/x86/hp/hp-bioscfg/string-attributes.c b/drivers/platform/x86/hp/hp-bioscfg/string-attributes.c
index f3dfba270f7e..095201004d87 100644
--- a/drivers/platform/x86/hp/hp-bioscfg/string-attributes.c
+++ b/drivers/platform/x86/hp/hp-bioscfg/string-attributes.c
@@ -101,8 +101,13 @@ static const struct attribute_group string_attr_group = {
int hp_alloc_string_data(void)
{
bioscfg_drv.string_instances_count = hp_get_instance_count(HP_WMI_BIOS_STRING_GUID);
- bioscfg_drv.string_data = kzalloc_objs(*bioscfg_drv.string_data,
- bioscfg_drv.string_instances_count);
+
+ if (!bioscfg_drv.string_instances_count)
+ return -EINVAL;
+ bioscfg_drv.string_data =
+ kvzalloc_objs(*bioscfg_drv.string_data,
+ bioscfg_drv.string_instances_count);
+
if (!bioscfg_drv.string_data) {
bioscfg_drv.string_instances_count = 0;
return -ENOMEM;
@@ -390,6 +395,6 @@ void hp_exit_string_attributes(void)
}
bioscfg_drv.string_instances_count = 0;
- kfree(bioscfg_drv.string_data);
+ kvfree(bioscfg_drv.string_data);
bioscfg_drv.string_data = NULL;
}
--
2.53.0
reply other threads:[~2026-09-25 19:45 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260925194454.6850-1-okuroshioffc@gmail.com \
--to=okuroshioffc@gmail.com \
--cc=hansg@kernel.org \
--cc=ilpo.jarvinen@linux.intel.com \
--cc=jorge.lopez2@hp.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@weissschuh.net \
--cc=platform-driver-x86@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®