platform/x86: hp-bioscfg: Support allocations of larger data
authorMario Limonciello <mario.limonciello@amd.com>
Wed, 25 Feb 2026 21:06:46 +0000 (15:06 -0600)
committerIlpo Järvinen <ilpo.jarvinen@linux.intel.com>
Fri, 27 Feb 2026 11:10:16 +0000 (13:10 +0200)
Some systems have much larger amounts of enumeration attributes
than have been previously encountered. This can lead to page allocation
failures when using kcalloc().  Switch over to using kvcalloc() to
allow larger allocations.

Fixes: 6b2770bfd6f92 ("platform/x86: hp-bioscfg: enum-attributes")
Cc: stable@vger.kernel.org
Reported-by: Paul Kerry <p.kerry@sheffield.ac.uk>
Tested-by: Paul Kerry <p.kerry@sheffield.ac.uk>
Closes: https://bugs.debian.org/1127612
Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
Link: https://patch.msgid.link/20260225210646.59381-1-mario.limonciello@amd.com
Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
drivers/platform/x86/hp/hp-bioscfg/enum-attributes.c

index 470b9f4..af4d192 100644 (file)
@@ -94,8 +94,11 @@ int hp_alloc_enumeration_data(void)
        bioscfg_drv.enumeration_instances_count =
                hp_get_instance_count(HP_WMI_BIOS_ENUMERATION_GUID);
 
-       bioscfg_drv.enumeration_data = kzalloc_objs(*bioscfg_drv.enumeration_data,
-                                                   bioscfg_drv.enumeration_instances_count);
+       if (!bioscfg_drv.enumeration_instances_count)
+               return -EINVAL;
+       bioscfg_drv.enumeration_data = kvcalloc(bioscfg_drv.enumeration_instances_count,
+                                               sizeof(*bioscfg_drv.enumeration_data), GFP_KERNEL);
+
        if (!bioscfg_drv.enumeration_data) {
                bioscfg_drv.enumeration_instances_count = 0;
                return -ENOMEM;
@@ -444,6 +447,6 @@ void hp_exit_enumeration_attributes(void)
        }
        bioscfg_drv.enumeration_instances_count = 0;
 
-       kfree(bioscfg_drv.enumeration_data);
+       kvfree(bioscfg_drv.enumeration_data);
        bioscfg_drv.enumeration_data = NULL;
 }