From: Bedant Patnaik <bedant.patnaik@gmail.com>
To: Hans de Goede <hdegoede@redhat.com>,
Jorge Lopez <jorgealtxwork@gmail.com>
Cc: Andy Shevchenko <andy@infradead.org>,
"markgross@kernel.org" <markgross@kernel.org>,
"platform-driver-x86@vger.kernel.org"
<platform-driver-x86@vger.kernel.org>
Subject: Re: [RFC] platform/x86: hp-wmi: make hp_wmi_perform_query() work with certain devices
Date: Wed, 08 Jun 2022 00:22:42 +0530 [thread overview]
Message-ID: <34dc40b7c51ee62825e4e063b77e40c0c842f2d5.camel@gmail.com> (raw)
In-Reply-To: <fd1b71fe-d9a7-65bb-314c-f11b7d550fe8@redhat.com>
From: Bedant Patnaik <bedant.patnaik@gmail.com>
Date: Tue, 7 Jun 2022 23:16:05 +0530
Subject: [PATCH] platform/x86: hp-wmi: make hp_wmi_perform_query() work with
certain devices
4b4967cbd2685f313411e6facf915fb2ae01d796 ("platform/x86: hp-wmi: Changing bios_args.data to be dynamically allocated")
broke WMI queries on some devices where the ACPI method HWMC unconditionally attempts to create Fields beyond the buffer
if the buffer is too small:
CreateByteField (Arg1, 0x10, D008)
CreateByteField (Arg1, 0x11, D009)
CreateByteField (Arg1, 0x12, D010)
CreateDWordField (Arg1, 0x10, D032)
CreateField (Arg1, 0x80, 0x0400, D128)
In cases where args->data had zero length, ACPI BIOS Error (bug): AE_AML_BUFFER_LIMIT, Field [D008] at bit
offset/length 128/8 exceeds size of target Buffer (128 bits) (20211217/dsopcode-198) was obtained.
Fix: allocate at least 128 bytes for args->data
Tested on Omen 15 AMD (2020) board ID: 8786.
Signed-off-by: Bedant Patnaik <bedant.patnaik@gmail.com>
---
drivers/platform/x86/hp-wmi.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/platform/x86/hp-wmi.c b/drivers/platform/x86/hp-wmi.c
index 667f94bba..7a54191f0 100644
--- a/drivers/platform/x86/hp-wmi.c
+++ b/drivers/platform/x86/hp-wmi.c
@@ -175,7 +175,7 @@ enum hp_thermal_profile_omen_v1 {
enum hp_thermal_profile {
HP_THERMAL_PROFILE_PERFORMANCE = 0x00,
HP_THERMAL_PROFILE_DEFAULT = 0x01,
- HP_THERMAL_PROFILE_COOL = 0x02
+ HP_THERMAL_PROFILE_COOL = 0x02,
};
#define IS_HWBLOCKED(x) ((x & HPWMI_POWER_FW_OR_HW) != HPWMI_POWER_FW_OR_HW)
@@ -297,8 +297,8 @@ static int hp_wmi_perform_query(int query, enum hp_wmi_command command,
if (WARN_ON(mid < 0))
return mid;
- bios_args_size = struct_size(args, data, insize);
- args = kmalloc(bios_args_size, GFP_KERNEL);
+ bios_args_size = max(struct_size(args, data, insize), struct_size(args, data, 128));
+ args = kzalloc(bios_args_size, GFP_KERNEL);
if (!args)
return -ENOMEM;
--
2.36.1
next prev parent reply other threads:[~2022-06-07 21:11 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-06-07 13:24 [RFC] platform/x86: hp-wmi: make hp_wmi_perform_query() work with certain devices Bedant Patnaik
2022-06-07 13:35 ` Hans de Goede
[not found] ` <CAOOmCE8QYEwh6TrgA=_sTcm4spkuk3rjMS4g78nbBbWXWUB2aQ@mail.gmail.com>
2022-06-07 17:25 ` Hans de Goede
2022-06-07 18:11 ` Jorge Lopez
2022-06-07 18:37 ` Bedant Patnaik
2022-06-07 19:47 ` Jorge Lopez
2022-06-08 19:28 ` Bedant Patnaik
2022-06-08 19:41 ` Bedant Patnaik
2022-06-09 13:50 ` Jorge Lopez
2022-06-09 15:09 ` Andy Shevchenko
2022-06-10 20:27 ` Hans de Goede
2022-06-07 19:20 ` Hans de Goede
2022-06-07 18:52 ` Bedant Patnaik [this message]
2022-06-07 18:54 ` Bedant Patnaik
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=34dc40b7c51ee62825e4e063b77e40c0c842f2d5.camel@gmail.com \
--to=bedant.patnaik@gmail.com \
--cc=andy@infradead.org \
--cc=hdegoede@redhat.com \
--cc=jorgealtxwork@gmail.com \
--cc=markgross@kernel.org \
--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