phy: usb: sunplus: Fix potential null-ptr-deref in sp_usb_phy_probe()
authorShang XiaoJing <shangxiaojing@huawei.com>
Fri, 25 Nov 2022 02:12:22 +0000 (10:12 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 1 Feb 2023 07:34:09 +0000 (08:34 +0100)
commitd838b5c99bcecd593b4710a93fce8fdbf122395b
tree5d6b0c5a43ca62352012cad0792e8c3df8ccfb03
parentbe960b061b894dc7e47c56e5784b04ba44c67107
phy: usb: sunplus: Fix potential null-ptr-deref in sp_usb_phy_probe()

[ Upstream commit 17eee264ef386ef30a69dd70e36f29893b85c170 ]

sp_usb_phy_probe() will call platform_get_resource_byname() that may fail
and return NULL. devm_ioremap() will use usbphy->moon4_res_mem->start as
input, which may causes null-ptr-deref. Check the ret value of
platform_get_resource_byname() to avoid the null-ptr-deref.

Fixes: 99d9ccd97385 ("phy: usb: Add USB2.0 phy driver for Sunplus SP7021")
Signed-off-by: Shang XiaoJing <shangxiaojing@huawei.com>
Link: https://lore.kernel.org/r/20221125021222.25687-1-shangxiaojing@huawei.com
Signed-off-by: Vinod Koul <vkoul@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/phy/sunplus/phy-sunplus-usb2.c