From: "Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>
To: Wentao Liang <vulab@iscas.ac.cn>
Cc: hmh@hmh.eng.br, Hans de Goede <hdegoede@redhat.com>,
ibm-acpi-devel@lists.sourceforge.net,
platform-driver-x86@vger.kernel.org,
LKML <linux-kernel@vger.kernel.org>,
stable@vger.kernel.org
Subject: Re: [PATCH] platform/x86: thinkpad-acpi: Add error handling for tpacpi_check_quirks
Date: Mon, 7 Apr 2025 14:38:31 +0300 (EEST) [thread overview]
Message-ID: <6850403a-dba8-2334-50f7-76cda9e9685f@linux.intel.com> (raw)
In-Reply-To: <20250402143807.3650-1-vulab@iscas.ac.cn>
On Wed, 2 Apr 2025, Wentao Liang wrote:
> In tpacpi_battery_init(), the return value of tpacpi_check_quirks() needs
> to be checked. The battery should not be hooked if there is no matched
> battery information in quirk table.
>
> Add an error check and return -ENODEV immediately if the device fail
> the check.
>
> Fixes: 1a32ebb26ba9 ("platform/x86: thinkpad_acpi: Support battery quirk")
> Cc: stable@vger.kernel.org
> Signed-off-by: Wentao Liang <vulab@iscas.ac.cn>
> ---
> drivers/platform/x86/thinkpad_acpi.c | 6 +++++-
> 1 file changed, 5 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/platform/x86/thinkpad_acpi.c b/drivers/platform/x86/thinkpad_acpi.c
> index 2cfb2ac3f465..a3227f60aa43 100644
> --- a/drivers/platform/x86/thinkpad_acpi.c
> +++ b/drivers/platform/x86/thinkpad_acpi.c
> @@ -9969,11 +9969,15 @@ static const struct tpacpi_quirk battery_quirk_table[] __initconst = {
>
> static int __init tpacpi_battery_init(struct ibm_init_struct *ibm)
> {
> + unsigned long r;
> +
> memset(&battery_info, 0, sizeof(battery_info));
>
> - tp_features.battery_force_primary = tpacpi_check_quirks(
> + r = tp_features.battery_force_primary = tpacpi_check_quirks(
Please don't do a double assignment. You can assign r to
tp_features.battery_force_primary after the if check.
> battery_quirk_table,
> ARRAY_SIZE(battery_quirk_table));
> + if (!r)
> + return -ENODEV;
>
> battery_hook_register(&battery_hook);
> return 0;
>
--
i.
prev parent reply other threads:[~2025-04-07 11:38 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-02 14:38 Wentao Liang
2025-04-07 11:38 ` Ilpo Järvinen [this message]
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=6850403a-dba8-2334-50f7-76cda9e9685f@linux.intel.com \
--to=ilpo.jarvinen@linux.intel.com \
--cc=hdegoede@redhat.com \
--cc=hmh@hmh.eng.br \
--cc=ibm-acpi-devel@lists.sourceforge.net \
--cc=linux-kernel@vger.kernel.org \
--cc=platform-driver-x86@vger.kernel.org \
--cc=stable@vger.kernel.org \
--cc=vulab@iscas.ac.cn \
/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®