* [PATCH v2] platform/x86: thinkpad-acpi: Add error check for tpacpi_check_quirks()
@ 2025-04-07 13:58 Wentao Liang
2025-04-07 16:30 ` Ilpo Järvinen
0 siblings, 1 reply; 2+ messages in thread
From: Wentao Liang @ 2025-04-07 13:58 UTC (permalink / raw)
To: hmh, hdegoede, ilpo.jarvinen
Cc: ibm-acpi-devel, platform-driver-x86, linux-kernel, Wentao Liang,
stable
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>
---
v2: Fix double assignment error.
drivers/platform/x86/thinkpad_acpi.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/drivers/platform/x86/thinkpad_acpi.c b/drivers/platform/x86/thinkpad_acpi.c
index 2cfb2ac3f465..93eaca3bd9d1 100644
--- a/drivers/platform/x86/thinkpad_acpi.c
+++ b/drivers/platform/x86/thinkpad_acpi.c
@@ -9973,7 +9973,9 @@ static int __init tpacpi_battery_init(struct ibm_init_struct *ibm)
tp_features.battery_force_primary = tpacpi_check_quirks(
battery_quirk_table,
- ARRAY_SIZE(battery_quirk_table));
+ ARRAY_SIZE(battery_quirk_table))
+ if (!tp_features.battery_force_primary)
+ return -ENODEV;
battery_hook_register(&battery_hook);
return 0;
--
2.42.0.windows.2
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH v2] platform/x86: thinkpad-acpi: Add error check for tpacpi_check_quirks()
2025-04-07 13:58 [PATCH v2] platform/x86: thinkpad-acpi: Add error check for tpacpi_check_quirks() Wentao Liang
@ 2025-04-07 16:30 ` Ilpo Järvinen
0 siblings, 0 replies; 2+ messages in thread
From: Ilpo Järvinen @ 2025-04-07 16:30 UTC (permalink / raw)
To: Wentao Liang
Cc: hmh, Hans de Goede, ibm-acpi-devel, platform-driver-x86, LKML,
stable
On Mon, 7 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>
> ---
> v2: Fix double assignment error.
>
> drivers/platform/x86/thinkpad_acpi.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/platform/x86/thinkpad_acpi.c b/drivers/platform/x86/thinkpad_acpi.c
> index 2cfb2ac3f465..93eaca3bd9d1 100644
> --- a/drivers/platform/x86/thinkpad_acpi.c
> +++ b/drivers/platform/x86/thinkpad_acpi.c
> @@ -9973,7 +9973,9 @@ static int __init tpacpi_battery_init(struct ibm_init_struct *ibm)
>
> tp_features.battery_force_primary = tpacpi_check_quirks(
> battery_quirk_table,
> - ARRAY_SIZE(battery_quirk_table));
> + ARRAY_SIZE(battery_quirk_table))
Fine, using the same variable is okay but this will fail build as remove
that semicolon.
> + if (!tp_features.battery_force_primary)
> + return -ENODEV;
>
> battery_hook_register(&battery_hook);
> return 0;
>
--
i.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2025-04-07 16:30 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-04-07 13:58 [PATCH v2] platform/x86: thinkpad-acpi: Add error check for tpacpi_check_quirks() Wentao Liang
2025-04-07 16:30 ` Ilpo Järvinen
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox