Commit 41ff66b
committed
thermal: core: Fix thermal zone governor cleanup issues
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.wysocki1 parent 761fdf4 commit 41ff66b
1 file changed
Lines changed: 4 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
964 | 964 | | |
965 | 965 | | |
966 | 966 | | |
| 967 | + | |
967 | 968 | | |
968 | 969 | | |
969 | 970 | | |
| |||
1610 | 1611 | | |
1611 | 1612 | | |
1612 | 1613 | | |
1613 | | - | |
| 1614 | + | |
| 1615 | + | |
1614 | 1616 | | |
| 1617 | + | |
1615 | 1618 | | |
1616 | 1619 | | |
1617 | 1620 | | |
| |||
1724 | 1727 | | |
1725 | 1728 | | |
1726 | 1729 | | |
1727 | | - | |
1728 | | - | |
1729 | 1730 | | |
1730 | 1731 | | |
1731 | 1732 | | |
| |||
0 commit comments