Message ID | 20240207202012.3506-1-W_Armin@gmx.de |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel+bounces-57007-ouuuleilei=gmail.com@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:168b:b0:106:860b:bbdd with SMTP id ma11csp2483469dyb; Wed, 7 Feb 2024 12:20:41 -0800 (PST) X-Google-Smtp-Source: AGHT+IHktKI+H8V9w19KVSfSzPml15qkRpKiNBuge/qTraB0xF6S9RONB9sLtpn4+ETodbP5cvXy X-Received: by 2002:a81:7604:0:b0:5ff:981a:2aa5 with SMTP id r4-20020a817604000000b005ff981a2aa5mr5815425ywc.46.1707337241239; Wed, 07 Feb 2024 12:20:41 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707337241; cv=pass; d=google.com; s=arc-20160816; b=N7FzdjFMn8g3z9jR8Ykd9oStx+elEtsT5+LWEaEd08ZW732clLskAeWRh5DdQ2avQ1 lMABvm2o1Gi7c0ZxYCjBhHUwEqQiMk77KrJXju2DmMUhDMPTRiOgMey14Tic2Ek0//d2 l0tEahwYEAr3J7d7c3iCwQIDpVcSJPXV6aMJKpjtC3qgNHTxhKuIexmfKUECqEaRt/WY Y+bVMtSG4r36W/oL7qSuPSwdX32GG+VWzpQV9PNu/bBCcZG/coDZXnF+1B2KFHETmtmD sxxvrelEJcfaax/nchWVh9oizycvlzuSb1FhG871JDyqORDNi/3LGSNJ3tCqgLhJW5cL zIkQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=ui-outboundreport:content-transfer-encoding:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:message-id:date :subject:cc:to:from:dkim-signature; bh=JhjI7wdH8MRQvsXtKIbEoGulNZdak8D1BlgS/cFExmQ=; fh=A2Qz1kbi7GmwKLr4KdqH2SQs8nPL8Yi5QkPzUsYTk3U=; b=U+QluIzjW2IIEAer0wJ8hGp4JTqJ9Fr64oAN8pAG1drg1mxzw4ClYEm5vPmvW5QNRF cQSgjnBzcwlHShW1MzcldOdCfZl2T4lE/6nqdfFuQLoLoF7GNyBV0WHqVfICPRX8c4hs rUYNtgPk+DNDM8UCOXODO28IyAhWDPYQ5scNfgOzTkh0IOR2T/tMXdYlrqkMoTK9Mw98 tAbV5sW0iTBBH5c2Hef2nBXK82yIRiQlJ+k7kbSia0+whocc9C8loo4LLAZp8T9JAxV7 NGuVN7l0dG6auOW14a46NvYI5dbvUSz13jKw8aSPL+j3xr153N9jYXGg6xTSxr4zph8U NYrw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmx.de header.s=s31663417 header.b=qCwrbggk; arc=pass (i=1 spf=pass spfdomain=gmx.de dkim=pass dkdomain=gmx.de dmarc=pass fromdomain=gmx.de); spf=pass (google.com: domain of linux-kernel+bounces-57007-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-57007-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=gmx.de X-Forwarded-Encrypted: i=2; AJvYcCVofXf2PHRogR3vZsjAVWO8nkBf0CyS57p7cQrULXTZ3f/9eSOxcXyq8aWyILnM1iba+dD6y/tg8GE+dF7VBbnOEoka+A== Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id u21-20020a05620a023500b007853e9ca5dcsi1736659qkm.241.2024.02.07.12.20.41 for <ouuuleilei@gmail.com> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 07 Feb 2024 12:20:41 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-57007-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@gmx.de header.s=s31663417 header.b=qCwrbggk; arc=pass (i=1 spf=pass spfdomain=gmx.de dkim=pass dkdomain=gmx.de dmarc=pass fromdomain=gmx.de); spf=pass (google.com: domain of linux-kernel+bounces-57007-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-57007-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=gmx.de Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 07BD01C226AF for <ouuuleilei@gmail.com>; Wed, 7 Feb 2024 20:20:41 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E971F127B48; Wed, 7 Feb 2024 20:20:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmx.de header.i=w_armin@gmx.de header.b="qCwrbggk" Received: from mout.gmx.net (mout.gmx.net [212.227.17.22]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2E06F126F01; Wed, 7 Feb 2024 20:20:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=212.227.17.22 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707337225; cv=none; b=YHAoZ4+kenQGZLQppLXuI9fTRF82uXVDoQ9PsjzS1tnzrYAlSSnU+IyTdngQC5gBEtefnWEgIXGsayVnWC0J1colicDGvgjNbSPi4DbmnmzPZ0WecBZR6/AvyrxoT2Yajj6TqMxkjhfc3Naa8+OiVHxGQqx52l6+bDBocOHLXcU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707337225; c=relaxed/simple; bh=Y20V3UzkaqA6wx/OLf/e4o3IW92eIo5mtjOtCYkhvhc=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=GLGabYfPYODpRuLJMHk3PFoT+VAIAnRlmhIiOZri96bHMuJuUq7PHzbKQtj4b7j+e/M3cAAIt8aPmNTJqwCeicakbstpdGT+Q9Y/YQGwQWlCxaFJ+1sN4o6LBi+KW/9nqJtVjEKg74NsgmpQslJe6/3xhnuH3O6pTpfcbDMfVaI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=gmx.de; spf=pass smtp.mailfrom=gmx.de; dkim=pass (2048-bit key) header.d=gmx.de header.i=w_armin@gmx.de header.b=qCwrbggk; arc=none smtp.client-ip=212.227.17.22 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=gmx.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmx.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.de; s=s31663417; t=1707337215; x=1707942015; i=w_armin@gmx.de; bh=Y20V3UzkaqA6wx/OLf/e4o3IW92eIo5mtjOtCYkhvhc=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date; b=qCwrbggk2YaiVuLiD/45AxLNkorhXfpC9zoSqP8otrLlYGp7Y6glF8jNnsV5mAxr CRKnX9QVmLen1HVs28a39fwRLmx6qTQnbPx/dipWdvb3iqZhnuiPK0f8Ym09KHrfK THiNrgT0Lk7HnQ/BoLgFTlKSZYUgXn/6Tr7bfRkFhyuTDNKoH2XccIIP2q1XdH/eq oVydlJ1JNTL50eKLYGIGUkQfLUkrwIqrZOsnr229wneTepykQ6Tnij/+VOxYPY5oZ w1kLvcyNsqYazDScIQ9N5lepiZq9xcUHlK30sKFWXQoODheIXdEP3izCbkwJqZUax SpqzKHzpsj0Sac43Xg== X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Received: from mx-amd-b650.users.agdsn.de ([141.30.226.129]) by mail.gmx.net (mrgmx105 [212.227.17.168]) with ESMTPSA (Nemesis) id 1M2f5T-1raIAi0gYh-004AJG; Wed, 07 Feb 2024 21:20:15 +0100 From: Armin Wolf <W_Armin@gmx.de> To: hdegoede@redhat.com, ilpo.jarvinen@linux.intel.com Cc: platform-driver-x86@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] platform/x86: wmi: Make input buffer madatory when evaulating methods Date: Wed, 7 Feb 2024 21:20:12 +0100 Message-Id: <20240207202012.3506-1-W_Armin@gmx.de> X-Mailer: git-send-email 2.39.2 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: <linux-kernel.vger.kernel.org> List-Subscribe: <mailto:linux-kernel+subscribe@vger.kernel.org> List-Unsubscribe: <mailto:linux-kernel+unsubscribe@vger.kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Provags-ID: V03:K1:3aVsqHOvhZZkL6tEUxNKYoS/mZgb807r4CifOkC1PmJXBmfOLIF uSuD2lAxXWIZPGhsXpt05mD7PY3lHxm3bui7IZsT1uzl2AWOfsV29G+plMBaGBg6YaEJHtF fhsT3O5awtDDOHmymg4da15+1RqLBl/zW9+ebQQqHI5BkWbDUIJQtR8OnImvxxX1Qda5sKD c8IkMiq0zVQ2vSb927mvQ== X-Spam-Flag: NO UI-OutboundReport: notjunk:1;M01:P0:GB9CGCrhmE0=;DXg19GSNS+0KObxmVvH1qe6KNi0 w1YRx2K0dQMj2Eqn8ohC+8TTRuNxg6625L/HlejmZWqPW8OH/4e0hoT/cEPkrhfKkTXaRrTiR GfRB1lOkQxjYdMv2zV2rUsCRkNRlrhjYT7H+2lcJZJZsgQWRuczQGMq9PlWUTpWIsCLy4v4Bj xjGbCwWdsZ5IKLQa3EaoEA9Ca4/G/JBdXtI8oj1ZBAKkSryF/OGostwr2JSCga6JOdLzgB5wV FEYYaotfAKAp8EG4glBuY9/UfWSrupvhiIVH2dqJ22zP5+pOo8Zy4nt0Cnj7TcglGn7HJZ4KF v2hkE980fRdUkxZKQJnmeX+jP6WfKLuWYYIS3HJtrK4BEhwyodbQBDUSMIqeX5Zinxc0dKu+w KyL2MfmAq36L+fAkl2flzQjzsU2JG7Bp0h44WGtYgRJve+Otm5ad0p2cuzDBKqHEr5fouNrZP ifpJ6whl7NDHkdzvfxm41q75WmK4GWEJ6SFPm+5x+08Ao8ZBE9qBnqCDeO+qS1Rh3caeXsVDI LywdfHERYfq6+SFk4KOYfoF15dyyTwkcd0nL40WRLizBsZe1CpGAZaNqo492Slsj4zWpr474V kwTX6ePzj5e2jfxkRhyLcSFypykko57Vv7QwriEqxs9NoffaMomaBqOq77n7CiuR7Z2s5Nhh3 jWq9tU02z0ZgS/L651+wF0tVrVYEGtjD0ThVOdQ0rlqmdJ6DV90kYAkZY2H1HYo5hDYyyeAnu dDOen5/6ioapTjhpxn2Vy11qH4leBzSCpCPdce7bfvBqrYUmU8uKnHIM84ILPsbS9xvM2FeGT e4YQN5gBnJTKc1la06+/I2ReLuvQbOOo6BdmQfc/H2VoQ= X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790272854976946770 X-GMAIL-MSGID: 1790272854976946770 |
Series |
platform/x86: wmi: Make input buffer madatory when evaulating methods
|
|
Commit Message
Armin Wolf
Feb. 7, 2024, 8:20 p.m. UTC
The ACPI-WMI specification declares that a WMxx control method takes
3 arguments: instance, method id and argument buffer. This is also
the case even when the underlying WMI method does not have any
input arguments.
So if a WMI driver evaluates a WMI method without passing an input
buffer, ACPICA will log a warning complaining that the third argument
is missing.
Prevent this by checking that a input buffer was passed, and return
an error if this was not the case.
Tested on a Asus PRIME B650-Plus.
Signed-off-by: Armin Wolf <W_Armin@gmx.de>
---
drivers/platform/x86/wmi.c | 21 ++++++++++-----------
1 file changed, 10 insertions(+), 11 deletions(-)
--
2.39.2
Comments
On 2/7/24 12:20 PM, Armin Wolf wrote: > The ACPI-WMI specification declares that a WMxx control method takes > 3 arguments: instance, method id and argument buffer. This is also > the case even when the underlying WMI method does not have any > input arguments. It would be better if you include specification version and section title for reference. > > So if a WMI driver evaluates a WMI method without passing an input > buffer, ACPICA will log a warning complaining that the third argument > is missing. I assume it is a compile warning. Can you copy the warning message? > > Prevent this by checking that a input buffer was passed, and return > an error if this was not the case. > > Tested on a Asus PRIME B650-Plus. > > Signed-off-by: Armin Wolf <W_Armin@gmx.de> > --- With above fixed, Reviewed-by: Kuppuswamy Sathyanarayanan <sathyanarayanan.kuppuswamy@linux.intel.com> > drivers/platform/x86/wmi.c | 21 ++++++++++----------- > 1 file changed, 10 insertions(+), 11 deletions(-) > > diff --git a/drivers/platform/x86/wmi.c b/drivers/platform/x86/wmi.c > index 63906fdd0abf..f9e23d491dd9 100644 > --- a/drivers/platform/x86/wmi.c > +++ b/drivers/platform/x86/wmi.c > @@ -296,7 +296,7 @@ EXPORT_SYMBOL_GPL(wmidev_instance_count); > * @guid_string: 36 char string of the form fa50ff2b-f2e8-45de-83fa-65417f2f49ba > * @instance: Instance index > * @method_id: Method ID to call > - * @in: Buffer containing input for the method call > + * @in: Mandatory buffer containing input for the method call > * @out: Empty buffer to return the method results > * > * Call an ACPI-WMI method, the caller must free @out. > @@ -326,7 +326,7 @@ EXPORT_SYMBOL_GPL(wmi_evaluate_method); > * @wdev: A wmi bus device from a driver > * @instance: Instance index > * @method_id: Method ID to call > - * @in: Buffer containing input for the method call > + * @in: Mandatory buffer containing input for the method call > * @out: Empty buffer to return the method results > * > * Call an ACPI-WMI method, the caller must free @out. > @@ -347,26 +347,25 @@ acpi_status wmidev_evaluate_method(struct wmi_device *wdev, u8 instance, u32 met > block = &wblock->gblock; > handle = wblock->acpi_device->handle; > > + if (!in) > + return AE_BAD_DATA; > + > if (!(block->flags & ACPI_WMI_METHOD)) > return AE_BAD_DATA; > > if (block->instance_count <= instance) > return AE_BAD_PARAMETER; > > - input.count = 2; > + input.count = 3; > input.pointer = params; > + > params[0].type = ACPI_TYPE_INTEGER; > params[0].integer.value = instance; > params[1].type = ACPI_TYPE_INTEGER; > params[1].integer.value = method_id; > - > - if (in) { > - input.count = 3; > - > - params[2].type = get_param_acpi_type(wblock); > - params[2].buffer.length = in->length; > - params[2].buffer.pointer = in->pointer; > - } > + params[2].type = get_param_acpi_type(wblock); > + params[2].buffer.length = in->length; > + params[2].buffer.pointer = in->pointer; > > get_acpi_method_name(wblock, 'M', method); > > -- > 2.39.2 > >
Am 08.02.24 um 03:41 schrieb Kuppuswamy Sathyanarayanan: > On 2/7/24 12:20 PM, Armin Wolf wrote: >> The ACPI-WMI specification declares that a WMxx control method takes >> 3 arguments: instance, method id and argument buffer. This is also >> the case even when the underlying WMI method does not have any >> input arguments. > It would be better if you include specification version and section > title for reference. The ACPI-WMI specification is not part of the ACPI specification. It consists of a single whitepaper published by Microsoft: https://github.com/microsoft/Windows-driver-samples/blob/main/wmi/wmiacpi/wmi-acpi.htm The section describing the ACPI control methods is called "ACPI Control Method Naming Conventions and Functionality for Windows 2000 Instrumentation". I do not thing that mentioning this in the commit message would be of any use. >> So if a WMI driver evaluates a WMI method without passing an input >> buffer, ACPICA will log a warning complaining that the third argument >> is missing. > I assume it is a compile warning. Can you copy the warning message? Its not a compiler warning. The ACPI control method is being evaluated at runtime, so the warning message will also be generated at runtime (when interpreting the AML bytecode). Thanks, Armin Wolf >> Prevent this by checking that a input buffer was passed, and return >> an error if this was not the case. >> >> Tested on a Asus PRIME B650-Plus. >> >> Signed-off-by: Armin Wolf <W_Armin@gmx.de> >> --- > > With above fixed, > > Reviewed-by: Kuppuswamy Sathyanarayanan <sathyanarayanan.kuppuswamy@linux.intel.com> > >> drivers/platform/x86/wmi.c | 21 ++++++++++----------- >> 1 file changed, 10 insertions(+), 11 deletions(-) >> >> diff --git a/drivers/platform/x86/wmi.c b/drivers/platform/x86/wmi.c >> index 63906fdd0abf..f9e23d491dd9 100644 >> --- a/drivers/platform/x86/wmi.c >> +++ b/drivers/platform/x86/wmi.c >> @@ -296,7 +296,7 @@ EXPORT_SYMBOL_GPL(wmidev_instance_count); >> * @guid_string: 36 char string of the form fa50ff2b-f2e8-45de-83fa-65417f2f49ba >> * @instance: Instance index >> * @method_id: Method ID to call >> - * @in: Buffer containing input for the method call >> + * @in: Mandatory buffer containing input for the method call >> * @out: Empty buffer to return the method results >> * >> * Call an ACPI-WMI method, the caller must free @out. >> @@ -326,7 +326,7 @@ EXPORT_SYMBOL_GPL(wmi_evaluate_method); >> * @wdev: A wmi bus device from a driver >> * @instance: Instance index >> * @method_id: Method ID to call >> - * @in: Buffer containing input for the method call >> + * @in: Mandatory buffer containing input for the method call >> * @out: Empty buffer to return the method results >> * >> * Call an ACPI-WMI method, the caller must free @out. >> @@ -347,26 +347,25 @@ acpi_status wmidev_evaluate_method(struct wmi_device *wdev, u8 instance, u32 met >> block = &wblock->gblock; >> handle = wblock->acpi_device->handle; >> >> + if (!in) >> + return AE_BAD_DATA; >> + >> if (!(block->flags & ACPI_WMI_METHOD)) >> return AE_BAD_DATA; >> >> if (block->instance_count <= instance) >> return AE_BAD_PARAMETER; >> >> - input.count = 2; >> + input.count = 3; >> input.pointer = params; >> + >> params[0].type = ACPI_TYPE_INTEGER; >> params[0].integer.value = instance; >> params[1].type = ACPI_TYPE_INTEGER; >> params[1].integer.value = method_id; >> - >> - if (in) { >> - input.count = 3; >> - >> - params[2].type = get_param_acpi_type(wblock); >> - params[2].buffer.length = in->length; >> - params[2].buffer.pointer = in->pointer; >> - } >> + params[2].type = get_param_acpi_type(wblock); >> + params[2].buffer.length = in->length; >> + params[2].buffer.pointer = in->pointer; >> >> get_acpi_method_name(wblock, 'M', method); >> >> -- >> 2.39.2 >> >>
On 2/8/24 10:22 AM, Armin Wolf wrote: > Am 08.02.24 um 03:41 schrieb Kuppuswamy Sathyanarayanan: > >> On 2/7/24 12:20 PM, Armin Wolf wrote: >>> The ACPI-WMI specification declares that a WMxx control method takes >>> 3 arguments: instance, method id and argument buffer. This is also >>> the case even when the underlying WMI method does not have any >>> input arguments. >> It would be better if you include specification version and section >> title for reference. > > The ACPI-WMI specification is not part of the ACPI specification. It > consists of a single whitepaper published by Microsoft: > > https://github.com/microsoft/Windows-driver-samples/blob/main/wmi/wmiacpi/wmi-acpi.htm > > The section describing the ACPI control methods is called > "ACPI Control Method Naming Conventions and Functionality for Windows 2000 Instrumentation". > > I do not thing that mentioning this in the commit message would be of any use. I think it is better to include this detail. But, since it is not a standard specification, I will let maintainer make this call. > >>> So if a WMI driver evaluates a WMI method without passing an input >>> buffer, ACPICA will log a warning complaining that the third argument >>> is missing. >> I assume it is a compile warning. Can you copy the warning message? > > Its not a compiler warning. > > The ACPI control method is being evaluated at runtime, so the warning message > will also be generated at runtime (when interpreting the AML bytecode). > Got it. > Thanks, > Armin Wolf > >>> Prevent this by checking that a input buffer was passed, and return >>> an error if this was not the case. >>> >>> Tested on a Asus PRIME B650-Plus. >>> >>> Signed-off-by: Armin Wolf <W_Armin@gmx.de> >>> --- >> >> With above fixed, >> >> Reviewed-by: Kuppuswamy Sathyanarayanan <sathyanarayanan.kuppuswamy@linux.intel.com> >> >>> drivers/platform/x86/wmi.c | 21 ++++++++++----------- >>> 1 file changed, 10 insertions(+), 11 deletions(-) >>> >>> diff --git a/drivers/platform/x86/wmi.c b/drivers/platform/x86/wmi.c >>> index 63906fdd0abf..f9e23d491dd9 100644 >>> --- a/drivers/platform/x86/wmi.c >>> +++ b/drivers/platform/x86/wmi.c >>> @@ -296,7 +296,7 @@ EXPORT_SYMBOL_GPL(wmidev_instance_count); >>> * @guid_string: 36 char string of the form fa50ff2b-f2e8-45de-83fa-65417f2f49ba >>> * @instance: Instance index >>> * @method_id: Method ID to call >>> - * @in: Buffer containing input for the method call >>> + * @in: Mandatory buffer containing input for the method call >>> * @out: Empty buffer to return the method results >>> * >>> * Call an ACPI-WMI method, the caller must free @out. >>> @@ -326,7 +326,7 @@ EXPORT_SYMBOL_GPL(wmi_evaluate_method); >>> * @wdev: A wmi bus device from a driver >>> * @instance: Instance index >>> * @method_id: Method ID to call >>> - * @in: Buffer containing input for the method call >>> + * @in: Mandatory buffer containing input for the method call >>> * @out: Empty buffer to return the method results >>> * >>> * Call an ACPI-WMI method, the caller must free @out. >>> @@ -347,26 +347,25 @@ acpi_status wmidev_evaluate_method(struct wmi_device *wdev, u8 instance, u32 met >>> block = &wblock->gblock; >>> handle = wblock->acpi_device->handle; >>> >>> + if (!in) >>> + return AE_BAD_DATA; >>> + >>> if (!(block->flags & ACPI_WMI_METHOD)) >>> return AE_BAD_DATA; >>> >>> if (block->instance_count <= instance) >>> return AE_BAD_PARAMETER; >>> >>> - input.count = 2; >>> + input.count = 3; >>> input.pointer = params; >>> + >>> params[0].type = ACPI_TYPE_INTEGER; >>> params[0].integer.value = instance; >>> params[1].type = ACPI_TYPE_INTEGER; >>> params[1].integer.value = method_id; >>> - >>> - if (in) { >>> - input.count = 3; >>> - >>> - params[2].type = get_param_acpi_type(wblock); >>> - params[2].buffer.length = in->length; >>> - params[2].buffer.pointer = in->pointer; >>> - } >>> + params[2].type = get_param_acpi_type(wblock); >>> + params[2].buffer.length = in->length; >>> + params[2].buffer.pointer = in->pointer; >>> >>> get_acpi_method_name(wblock, 'M', method); >>> >>> -- >>> 2.39.2 >>> >>> >
diff --git a/drivers/platform/x86/wmi.c b/drivers/platform/x86/wmi.c index 63906fdd0abf..f9e23d491dd9 100644 --- a/drivers/platform/x86/wmi.c +++ b/drivers/platform/x86/wmi.c @@ -296,7 +296,7 @@ EXPORT_SYMBOL_GPL(wmidev_instance_count); * @guid_string: 36 char string of the form fa50ff2b-f2e8-45de-83fa-65417f2f49ba * @instance: Instance index * @method_id: Method ID to call - * @in: Buffer containing input for the method call + * @in: Mandatory buffer containing input for the method call * @out: Empty buffer to return the method results * * Call an ACPI-WMI method, the caller must free @out. @@ -326,7 +326,7 @@ EXPORT_SYMBOL_GPL(wmi_evaluate_method); * @wdev: A wmi bus device from a driver * @instance: Instance index * @method_id: Method ID to call - * @in: Buffer containing input for the method call + * @in: Mandatory buffer containing input for the method call * @out: Empty buffer to return the method results * * Call an ACPI-WMI method, the caller must free @out. @@ -347,26 +347,25 @@ acpi_status wmidev_evaluate_method(struct wmi_device *wdev, u8 instance, u32 met block = &wblock->gblock; handle = wblock->acpi_device->handle; + if (!in) + return AE_BAD_DATA; + if (!(block->flags & ACPI_WMI_METHOD)) return AE_BAD_DATA; if (block->instance_count <= instance) return AE_BAD_PARAMETER; - input.count = 2; + input.count = 3; input.pointer = params; + params[0].type = ACPI_TYPE_INTEGER; params[0].integer.value = instance; params[1].type = ACPI_TYPE_INTEGER; params[1].integer.value = method_id; - - if (in) { - input.count = 3; - - params[2].type = get_param_acpi_type(wblock); - params[2].buffer.length = in->length; - params[2].buffer.pointer = in->pointer; - } + params[2].type = get_param_acpi_type(wblock); + params[2].buffer.length = in->length; + params[2].buffer.pointer = in->pointer; get_acpi_method_name(wblock, 'M', method);