* [PATCH] phy: usb: sunplus: Fix potential null-ptr-deref in sp_usb_phy_probe()
@ 2022-11-25 2:12 Shang XiaoJing
2023-01-12 18:14 ` Vinod Koul
0 siblings, 1 reply; 2+ messages in thread
From: Shang XiaoJing @ 2022-11-25 2:12 UTC (permalink / raw)
To: vincent.sunplus, kishon, vkoul, linux-usb, linux-phy; +Cc: shangxiaojing
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>
---
drivers/phy/sunplus/phy-sunplus-usb2.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/phy/sunplus/phy-sunplus-usb2.c b/drivers/phy/sunplus/phy-sunplus-usb2.c
index b932087c55b2..6816b7d2318d 100644
--- a/drivers/phy/sunplus/phy-sunplus-usb2.c
+++ b/drivers/phy/sunplus/phy-sunplus-usb2.c
@@ -254,6 +254,9 @@ static int sp_usb_phy_probe(struct platform_device *pdev)
return PTR_ERR(usbphy->phy_regs);
usbphy->moon4_res_mem = platform_get_resource_byname(pdev, IORESOURCE_MEM, "moon4");
+ if (!usbphy->moon4_res_mem)
+ return -EINVAL;
+
usbphy->moon4_regs = devm_ioremap(&pdev->dev, usbphy->moon4_res_mem->start,
resource_size(usbphy->moon4_res_mem));
if (IS_ERR(usbphy->moon4_regs))
--
2.17.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] phy: usb: sunplus: Fix potential null-ptr-deref in sp_usb_phy_probe()
2022-11-25 2:12 [PATCH] phy: usb: sunplus: Fix potential null-ptr-deref in sp_usb_phy_probe() Shang XiaoJing
@ 2023-01-12 18:14 ` Vinod Koul
0 siblings, 0 replies; 2+ messages in thread
From: Vinod Koul @ 2023-01-12 18:14 UTC (permalink / raw)
To: Shang XiaoJing; +Cc: vincent.sunplus, kishon, linux-usb, linux-phy
On 25-11-22, 10:12, Shang XiaoJing wrote:
> 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.
Applied, thanks
--
~Vinod
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2023-01-12 18:43 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-11-25 2:12 [PATCH] phy: usb: sunplus: Fix potential null-ptr-deref in sp_usb_phy_probe() Shang XiaoJing
2023-01-12 18:14 ` Vinod Koul
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).