Re: [PATCH 2/3] hwmon: lenovo-ec-sensors: Fix NULL pointer dereference when DMI match fails
From: Kean
Date: Fri May 15 2026 - 04:15:10 EST
Hi Guenter,
Thank you for the review and for pointing this out!
You're absolutely right. I realize now that my patch was overly
cautious — in normal operation dmi_first_match() can never return
NULL here because lenovo_ec_init() already guards the probe behind:
static int __init lenovo_ec_init(void)
{
if (!dmi_check_system(thinkstation_dmi_table))
return -ENODEV;
...
}
That said, I tend to follow a defensive programming style — checking
for errors and returning early whenever something looks even slightly
unexpected. This is exactly what lenovo_ec_init() itself does with
dmi_check_system(), and it's also why we often put a return (or break)
in the default branch of a switch statement. So I added the NULL check
for dmi_first_match() as an extra sanity guard, even though logically
it should never trigger.
I should have made this clearer in the commit message. The patch was
meant as a defensive sanity check, but my description made it sound
like an actual reachable bug, which it isn't. That's my mistake.
I'm happy to drop this patch from the series if you'd prefer. Please
let me know how you'd like me to proceed.
For other parts and the format issues is my mistake that missed the
--strict to check the patches file, I will send the V2 version, hope
get your review, any problem you can tell me, I will feedback and
tested as your requested.
Thanks,
Kean