[<prev] [next>] [day] [month] [year] [list]
Message-ID: <20241025070744.149070-1-hanchunchao@inspur.com>
Date: Fri, 25 Oct 2024 15:07:44 +0800
From: Charles Han <hanchunchao@...pur.com>
To: <stanley_chang@...ltek.com>, <vkoul@...nel.org>, <kishon@...nel.org>,
<gregkh@...uxfoundation.org>
CC: <johan+linaro@...nel.org>, <u.kleine-koenig@...libre.com>,
<linux-phy@...ts.infradead.org>, <linux-kernel@...r.kernel.org>, Charles Han
<hanchunchao@...pur.com>
Subject: [PATCH] phy: realtek: usb: fix NULL deref in rtk_usb3phy_probe
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@...pur.com>
---
drivers/phy/realtek/phy-rtk-usb3.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/phy/realtek/phy-rtk-usb3.c b/drivers/phy/realtek/phy-rtk-usb3.c
index 0cef29a7ddd9..cce453686db2 100644
--- a/drivers/phy/realtek/phy-rtk-usb3.c
+++ b/drivers/phy/realtek/phy-rtk-usb3.c
@@ -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));
--
2.31.1
Powered by blists - more mailing lists