]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
phy: realtek: usb: fix NULL deref in rtk_usb3phy_probe
authorCharles Han <hanchunchao@inspur.com>
Fri, 25 Oct 2024 07:07:44 +0000 (15:07 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 4 Nov 2024 01:03:19 +0000 (02:03 +0100)
In rtk_usb3phy_probe() devm_kzalloc() may return NULL
but this returned value is not checked.

Fixes: adda6e82a7de ("phy: realtek: usb: Add driver for the Realtek SoC USB 3.0 PHY")
Signed-off-by: Charles Han <hanchunchao@inspur.com>
Link: https://lore.kernel.org/r/20241025070744.149070-1-hanchunchao@inspur.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/phy/realtek/phy-rtk-usb3.c

index dfcf4b921bba631d9511cfa04b1da38ac0350d68..96af483e5444b95a309e39b6f1a0fb57131cdac2 100644 (file)
@@ -577,6 +577,8 @@ static int rtk_usb3phy_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));