thermal/core: Fix null pointer dereference in thermal_release()
authorYuanzheng Song <songyuanzheng@huawei.com>
Fri, 15 Oct 2021 08:32:30 +0000 (08:32 +0000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 18 Nov 2021 18:16:16 +0000 (19:16 +0100)
commit38ef472ca8e59c971984922ad3b60d5338c16deb
tree0ddf86e99e8f299bc9f4a481e6c5025800a7f2a8
parent7c0caa7e26368639f19f54b343b4a7d7d1f5b200
thermal/core: Fix null pointer dereference in thermal_release()

[ Upstream commit 1dd7128b839f631b31a9e9dce3aaf639bef74e9d ]

If both dev_set_name() and device_register() failed, then null pointer
dereference occurs in thermal_release() which will use strncmp() to
compare the name.

So fix it by adding dev_set_name() return value check.

Signed-off-by: Yuanzheng Song <songyuanzheng@huawei.com>
Link: https://lore.kernel.org/r/20211015083230.67658-1-songyuanzheng@huawei.com
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/thermal/thermal_core.c