public inbox for linux-phy@lists.infradead.org
 help / color / mirror / Atom feed
* [PATCH] phy: qcom-qmp-usb: Fix an NULL vs IS_ERR() bug
@ 2025-04-13 21:25 Chenyuan Yang
  2025-04-14  6:57 ` Johan Hovold
  2025-04-14  7:30 ` Krzysztof Kozlowski
  0 siblings, 2 replies; 7+ messages in thread
From: Chenyuan Yang @ 2025-04-13 21:25 UTC (permalink / raw)
  To: vkoul, kishon, lumag, quic_kriskura, manivannan.sadhasivam,
	konrad.dybcio, quic_varada, quic_kbajaj, johan+linaro
  Cc: linux-arm-msm, linux-phy, linux-kernel, Chenyuan Yang

In qmp_usb_iomap(), one branch returns the result of devm_ioremap(), which
can be NULL. Since IS_ERR() does not catch a NULL pointer,
add an explicit NULL check in qmp_usb_parse_dt_legacy() to prevent
potential dereference issues.

Signed-off-by: Chenyuan Yang <chenyuan0y@gmail.com>
Fixes: 2a55ec4f0a04 ("phy: qcom-qmp-usb: merge driver data")
---
 drivers/phy/qualcomm/phy-qcom-qmp-usb.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/phy/qualcomm/phy-qcom-qmp-usb.c b/drivers/phy/qualcomm/phy-qcom-qmp-usb.c
index 787721570457..8dab20b0c11c 100644
--- a/drivers/phy/qualcomm/phy-qcom-qmp-usb.c
+++ b/drivers/phy/qualcomm/phy-qcom-qmp-usb.c
@@ -2152,6 +2152,8 @@ static int qmp_usb_parse_dt_legacy(struct qmp_usb *qmp, struct device_node *np)
 		return PTR_ERR(qmp->rx);
 
 	qmp->pcs = qmp_usb_iomap(dev, np, 2, exclusive);
+	if (!qmp->pcs)
+		return -ENOMEM;
 	if (IS_ERR(qmp->pcs))
 		return PTR_ERR(qmp->pcs);
 
-- 
2.34.1


-- 
linux-phy mailing list
linux-phy@lists.infradead.org
https://lists.infradead.org/mailman/listinfo/linux-phy

^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2025-04-14 12:58 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-04-13 21:25 [PATCH] phy: qcom-qmp-usb: Fix an NULL vs IS_ERR() bug Chenyuan Yang
2025-04-14  6:57 ` Johan Hovold
2025-04-14  7:30 ` Krzysztof Kozlowski
2025-04-14  7:40   ` Johan Hovold
2025-04-14  8:08     ` Krzysztof Kozlowski
2025-04-14  8:13       ` Johan Hovold
2025-04-14 12:52         ` Chenyuan Yang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox