Commit 37a430a
thermal: core: Fix thermal zone governor cleanup issues
[ Upstream commit 41ff66b ]
If thermal_zone_device_register_with_trips() fails after adding
a thermal governor to the thermal zone being registered, the
governor is not removed from it as appropriate which may lead to
a memory leak.
In turn, thermal_zone_device_unregister() calls thermal_set_governor()
without acquiring the thermal zone lock beforehand which may race with
a governor update via sysfs and may lead to a use-after-free in that
case.
Address these issues by adding two thermal_set_governor() calls, one to
thermal_release() to remove the governor from the given thermal zone,
and one to the thermal zone registration error path to cover failures
preceding the thermal zone device registration.
Fixes: e33df1d ("thermal: let governors have private data for each thermal zone")
Cc: All applicable <stable@vger.kernel.org>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Link: https://patch.msgid.link/5092923.31r3eYUQgx@rafael.j.wysocki
[ kept the `thermal_zone_create_device_groups(tz, mask)` signature when adding the new failure-path cleanup ]
Signed-off-by: Sasha Levin <sashal@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>1 parent 78509c4 commit 37a430a
1 file changed
Lines changed: 4 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
804 | 804 | | |
805 | 805 | | |
806 | 806 | | |
| 807 | + | |
807 | 808 | | |
808 | 809 | | |
809 | 810 | | |
| |||
1325 | 1326 | | |
1326 | 1327 | | |
1327 | 1328 | | |
1328 | | - | |
| 1329 | + | |
| 1330 | + | |
1329 | 1331 | | |
| 1332 | + | |
1330 | 1333 | | |
1331 | 1334 | | |
1332 | 1335 | | |
| |||
1478 | 1481 | | |
1479 | 1482 | | |
1480 | 1483 | | |
1481 | | - | |
1482 | | - | |
1483 | 1484 | | |
1484 | 1485 | | |
1485 | 1486 | | |
| |||
0 commit comments