Message ID | 20250413212518.2625540-1-chenyuan0y@gmail.com |
---|---|
State | New |
Headers | show |
Series | phy: qcom-qmp-usb: Fix an NULL vs IS_ERR() bug | expand |
On 13/04/2025 23:25, Chenyuan Yang wrote: > 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, No, that's not true. NAK. Best regards, Krzysztof
On Mon, Apr 14, 2025 at 09:30:19AM +0200, Krzysztof Kozlowski wrote: > On 13/04/2025 23:25, Chenyuan Yang wrote: > > 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, > > No, that's not true. NAK. I'm afraid you're mistaken here. See __devm_ioremap() which can return NULL. Johan
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);
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(+)