thermal/core: fix error code in __thermal_cooling_device_register()
authorDan Carpenter <dan.carpenter@oracle.com>
Fri, 28 Oct 2022 15:02:34 +0000 (18:02 +0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 1 Feb 2023 07:27:15 +0000 (08:27 +0100)
commited08f958e481268a755b30e91958a821d0f55586
treeca2de6eafa9afc9d2a655894fb4a55fcd42e3cde
parent108a6f91e2766a6d9142b1f2d90c07ac547eae7e
thermal/core: fix error code in __thermal_cooling_device_register()

[ Upstream commit e49a1e1ee078aee21006192076a8d93335e0daa9 ]

Return an error pointer if ->get_max_state() fails.  The current code
returns NULL which will cause an oops in the callers.

Fixes: c408b3d1d9bb ("thermal: Validate new state in cur_state_store()")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Stable-dep-of: 6c54b7bc8a31 ("thermal: core: call put_device() only after device_register() fails")
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/thermal/thermal_core.c