Skip to contentSkip to conversation

usb: dwc3: qcom: Fix error handling in probe

PATCH In review Dan Carpenter 3 participants 3 messages Apr 23, 2025 – Apr 24, 2025

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 usb: dwc3: qcom: Fix error handling in probe

There are two issues:
1) Return -EINVAL if platform_get_resource() fails. Don't return success.
2) The devm_ioremap() function doesn't return error pointers, it returns NULL. Update the check.

Fixes 1881a32fe14d ("usb: dwc3: qcom: Transition to flattened model")
---
 drivers/usb/dwc3/dwc3-qcom.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)
drivers/usb/dwc3/dwc3-qcom.c +6 -4
index d512002e1e88..b63fcaf823aa 100644
@@ -740,15 +740,17 @@ static int dwc3_qcom_probe(struct platform_device *pdev)
 	}
 
 	r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-	if (!r)
+	if (!r) {
+		ret = -EINVAL;
 		goto clk_disable;
+	}
 	res = *r;
 	res.end = res.start + SDM845_QSCRATCH_BASE_OFFSET;
 
 	qcom->qscratch_base = devm_ioremap(dev, res.end, SDM845_QSCRATCH_SIZE);
-	if (IS_ERR(qcom->qscratch_base)) {
-		dev_err(dev, "failed to map qscratch region: %pe\n", qcom->qscratch_base);
-		ret = PTR_ERR(qcom->qscratch_base);
+	if (!qcom->qscratch_base) {
+		dev_err(dev, "failed to map qscratch region\n");
+		ret = -ENOMEM;
 		goto clk_disable;
 	}
 
Signature · 1 line
2.47.2
Reviewed-by on v1 1/1
#1 lore raw
Quoted 8 lines · Dan Carpenter

There are two issues:
1) Return -EINVAL if platform_get_resource() fails. Don't return success.
2) The devm_ioremap() function doesn't return error pointers, it returns NULL. Update the check.

Fixes 1881a32fe14d ("usb: dwc3: qcom: Transition to flattened model")

Regards,
Bjorn

Quoted 34 lines
---
 drivers/usb/dwc3/dwc3-qcom.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)
drivers/usb/dwc3/dwc3-qcom.c +6 -4
index d512002e1e88..b63fcaf823aa 100644
@@ -740,15 +740,17 @@ static int dwc3_qcom_probe(struct platform_device *pdev)
 	}
 
 	r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-	if (!r)
+	if (!r) {
+		ret = -EINVAL;
 		goto clk_disable;
+	}
 	res = *r;
 	res.end = res.start + SDM845_QSCRATCH_BASE_OFFSET;
 
 	qcom->qscratch_base = devm_ioremap(dev, res.end, SDM845_QSCRATCH_SIZE);
-	if (IS_ERR(qcom->qscratch_base)) {
-		dev_err(dev, "failed to map qscratch region: %pe\n", qcom->qscratch_base);
-		ret = PTR_ERR(qcom->qscratch_base);
+	if (!qcom->qscratch_base) {
+		dev_err(dev, "failed to map qscratch region\n");
+		ret = -ENOMEM;
 		goto clk_disable;
 	}
 
Signature · 1 line
2.47.2
maintainer Acked-by on v1 1/1
#2 lore raw
In reply to Dan Carpenter
Quoted 41 lines · Dan Carpenter

There are two issues:
1) Return -EINVAL if platform_get_resource() fails. Don't return success.
2) The devm_ioremap() function doesn't return error pointers, it returns NULL. Update the check.

Fixes 1881a32fe14d ("usb: dwc3: qcom: Transition to flattened model")
---
 drivers/usb/dwc3/dwc3-qcom.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)
drivers/usb/dwc3/dwc3-qcom.c +6 -4
index d512002e1e88..b63fcaf823aa 100644
@@ -740,15 +740,17 @@ static int dwc3_qcom_probe(struct platform_device *pdev)
 	}
 
 	r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-	if (!r)
+	if (!r) {
+		ret = -EINVAL;
 		goto clk_disable;
+	}
 	res = *r;
 	res.end = res.start + SDM845_QSCRATCH_BASE_OFFSET;
 
 	qcom->qscratch_base = devm_ioremap(dev, res.end, SDM845_QSCRATCH_SIZE);
-	if (IS_ERR(qcom->qscratch_base)) {
-		dev_err(dev, "failed to map qscratch region: %pe\n", qcom->qscratch_base);
-		ret = PTR_ERR(qcom->qscratch_base);
+	if (!qcom->qscratch_base) {
+		dev_err(dev, "failed to map qscratch region\n");
+		ret = -ENOMEM;
 		goto clk_disable;
 	}
 
Signature · 1 line
2.47.2

Thanks,
Thinh