Commit 04e3e918 authored by Charles Han's avatar Charles Han Committed by Greg Kroah-Hartman
Browse files

phy: realtek: usb: fix NULL deref in rtk_usb2phy_probe



In rtk_usb2phy_probe() devm_kzalloc() may return NULL
but this returned value is not checked.

Fixes: 134e6d25 ("phy: realtek: usb: Add driver for the Realtek SoC USB 2.0 PHY")
Signed-off-by: default avatarCharles Han <hanchunchao@inspur.com>
Link: https://lore.kernel.org/r/20241025065912.143692-1-hanchunchao@inspur.com


Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 7c561b8c
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -1023,6 +1023,8 @@ static int rtk_usb2phy_probe(struct platform_device *pdev)

	rtk_phy->dev			= &pdev->dev;
	rtk_phy->phy_cfg = devm_kzalloc(dev, sizeof(*phy_cfg), GFP_KERNEL);
	if (!rtk_phy->phy_cfg)
		return -ENOMEM;

	memcpy(rtk_phy->phy_cfg, phy_cfg, sizeof(*phy_cfg));