Re: [PATCH] ACPI: lpat: Avoid division by zero on degenerate LPAT tables

From: Andy Shevchenko

Date: Sat Nov 07 2026 - 08:56:14 EST


On Sat, Nov 7, 2026 at 3:01 PM <shao.mingyin@xxxxxxxxxx> wrote:
>
> acpi_lpat_raw_to_temp() and acpi_lpat_temp_to_raw() linearly interpolate
> between consecutive LPAT table entries by dividing the difference of the
> other coordinate by delta_raw or delta_temp. The table is provided by
> the firmware through the LPAT control method and
> acpi_lpat_get_conversion_table() only checks the package shape and the
> element types, so nothing guarantees that two adjacent entries have
> distinct raw (or temperature) values.
>
> If the queried value lies between two consecutive entries that share the
> same raw value, delta_raw is zero and acpi_lpat_raw_to_temp() traps with
> a #DE exception and oopses the kernel. The same happens in
> acpi_lpat_temp_to_raw() when two adjacent entries share the same
> temperature. Callers such as int340x thermal zones and the Intel PMIC
> opregion handlers pass firmware-controlled values straight into these
> functions, so a malformed LPAT object is enough to trigger the trap.
>
> Return the endpoint value instead of dividing when the delta is zero. In
> that case the query value necessarily equals the shared endpoint, so the
> other coordinate of that entry is the natural fallback and no interpolation
> is possible.

> Fixes: c55d62820efe ("ACPI / LPAT: Common table processing functions")

I'm not objecting to the code, but this is not a fix, it's hardening
for sure, otherwise your expectation is that we have such a table IRL.
If so, this commit message should have a pointer.

--
With Best Regards,
Andy Shevchenko