]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
Revert "thermal/drivers/hwmon: Cleanup coding style a bit"
authorRafael J. Wysocki <rafael.j.wysocki@intel.com>
Tue, 4 Aug 2026 20:09:10 +0000 (22:09 +0200)
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>
Wed, 5 Aug 2026 11:25:55 +0000 (13:25 +0200)
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/20260803183915.4ED7D1F000E9@smtp.kernel.org/
Cc: All applicable <stable@vger.kernel.org>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Reviewed-by: Lukasz Luba <lukasz.luba@arm.com>
Link: https://patch.msgid.link/5123895.31r3eYUQgx@rafael.j.wysocki
drivers/thermal/thermal_hwmon.c

index 597c33c8a55508e0aac8a288313624a8fc85074d..ec73d03a1e60a20915a952128032ab8081d4d701 100644 (file)
@@ -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;
 }