CVE-2023-53012: thermal: core: call put_device() only after device_register() fails
Description
===========
In the Linux kernel, the following vulnerability has been resolved:
thermal: core: call put_device() only after device_register() fails
put_device() shouldn't be called before a prior call to device_register(). __thermal_cooling_device_register() doesn't follow that properly and needs fixing. Also thermal_cooling_device_destroy_sysfs() is getting called unnecessarily on few error paths.
Fix all this by placing the calls at the right place.
Based on initial work done by Caleb Connolly.
The Linux kernel CVE team has assigned CVE-2023-53012 to this issue.
Affected and fixed versions
===========================
Issue introduced in 5.15.86 with commit 5139cbc0c6e4bf2fcffc9a7ed4350bf6985bc561 Issue introduced in 6.0.16 with commit c4c435d3637b5d0abaa6447c7366c3674364968a Issue introduced in 6.1.2 with commit e0d8b51bbe84d6a98c162e06344de2d773d9e722
Please see https://www.kernel.org for a full list of currently supported kernel versions by the kernel community.
Unaffected versions might change over time as fixes are backported to older supported kernel versions. The official CVE entry at
https://cve.org/CVERecord/?id=CVE-2023-53012
will be updated if fixes are backported, please check that for the most up to date information about this issue.
Affected files
==============
The file(s) affected by this issue are:
drivers/thermal/thermal_core.c
Mitigation
==========
The Linux kernel CVE team recommends that you update to the latest stable kernel version for this, and many other bugfixes. Individual changes are never tested alone, but rather are part of a larger kernel release. Cherry-picking individual commits is not recommended or supported by the Linux kernel community at all. If however, updating to the latest release is impossible, the individual changes to resolve this issue can be found at these commits:
https://git.kernel.org/stable/c/a7d736cc3c6cb0d7498bbfb56515d414e35e9510 https://git.kernel.org/stable/c/2846a7412f6246fd5171f51011bf76dfebcec0ee https://git.kernel.org/stable/c/6c54b7bc8a31ce0f7cc7f8deef05067df414f1d8