Re: [PATCH v2 1/2] Revert "thermal/drivers/hwmon: Cleanup coding style a bit"
"Rafael J. Wysocki (Intel)" <[email protected]> Wed, 5 Aug 2026 13:53:22 +0200
| Newsgroups | org.kernel.vger.linux-hwmon,org.kernel.vger.linux-acpi,org.kernel.vger.linux-kernel,org.kernel.vger.linux-pm |
|---|---|
| Message-ID | <CAJZ5v0iH0oewk3EVjRKsJqaOC23LdKURzttCgEoJqLqeobPBrA@mail.gmail.com> |
On Wed, Aug 5, 2026 at 12:32 PM Lukasz Luba <[email protected]> wrote: > > > > On 8/4/26 21:09, Rafael J. Wysocki wrote: > > From: "Rafael J. Wysocki" <[email protected]> > > > > Revert commit 030a48b0f6ce ("thermal/drivers/hwmon: Cleanup coding style > > a bit") that introduced a use-after-free into the error path of > > thermal_add_hwmon_sysfs() by removing a valid check from it. > > > > Link: https://lore.kernel.org/linux-hwmon/[email protected]/ > > Cc: All applicable <[email protected]> > > Signed-off-by: Rafael J. Wysocki <[email protected]> > > --- > > drivers/thermal/thermal_hwmon.c | 3 ++- > > 1 file changed, 2 insertions(+), 1 deletion(-) > > > > diff --git a/drivers/thermal/thermal_hwmon.c b/drivers/thermal/thermal_hwmon.c > > index 597c33c8a555..ec73d03a1e60 100644 > > --- a/drivers/thermal/thermal_hwmon.c > > +++ b/drivers/thermal/thermal_hwmon.c > > @@ -212,7 +212,8 @@ int thermal_add_hwmon_sysfs(struct thermal_zone_device *tz) > > if (new_hwmon_device) > > hwmon_device_unregister(hwmon->device); > > free_mem: > > - kfree(hwmon); > > + if (new_hwmon_device) > > + kfree(hwmon); > > > > return result; > > } > > LGTM, a tricky plumbing. I'm sorry for being late with review. No worries. > Reviewed-by: Lukasz Luba <[email protected]> And thanks!