Skip to contentSkip to conversation

usb: dwc3: qcom: Fix NULL vs IS_ERR checking in dwc3_qcom_probe

PATCH Superseded Miaoqian Lin 2 participants 3 messages Dec 22, 2021

Subsystems (3)

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 usb: dwc3: qcom: Fix NULL vs IS_ERR checking in dwc3_qcom_probe

Since the acpi_create_platform_device() function may return error pointers, dwc3_qcom_create_urs_usb_platdev() function may return errors too. Using IS_ERR_OR_NULL() to check the return value to fix this.

Fixes c25c210f590e("usb: dwc3: qcom: add URS Host support for sdm845 ACPI boot")
---
 drivers/usb/dwc3/dwc3-qcom.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/usb/dwc3/dwc3-qcom.c +2 -2
index 3cb01cdd02c2..df27d903ba98 100644
@@ -769,9 +769,9 @@ static int dwc3_qcom_probe(struct platform_device *pdev)
 
 		if (qcom->acpi_pdata->is_urs) {
 			qcom->urs_usb = dwc3_qcom_create_urs_usb_platdev(dev);
-			if (!qcom->urs_usb) {
+			if (IS_ERR_OR_NULL(qcom->urs_usb)) {
 				dev_err(dev, "failed to create URS USB platdev\n");
-				return -ENODEV;
+				return qcom->urs_usb ? PTR_ERR(qcom->urs_usb) : -ENODEV;
 			}
 		}
 	}
Signature · 1 line
2.17.1
#1 lore raw

[note, you got the to: line incorrect...]

Quoted 5 lines · Miaoqian Lin

Since the acpi_create_platform_device() function may return error pointers, dwc3_qcom_create_urs_usb_platdev() function may return errors too. Using IS_ERR_OR_NULL() to check the return value to fix this.

Fixes c25c210f590e("usb: dwc3: qcom: add URS Host support for sdm845 ACPI boot")

Nit, the documentation says this should be:

Fixes c25c210f590e ("usb: dwc3: qcom: add URS Host support for sdm845 ACPI boot")
Quoted 10 lines
---
 drivers/usb/dwc3/dwc3-qcom.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/usb/dwc3/dwc3-qcom.c +0 -0
index 3cb01cdd02c2..df27d903ba98 100644

drivers/usb/dwc3/dwc3-qcom.c static int dwc3_qcom_probe(struct platform_device *pdev) · line 774

Quoted 8 lines
drivers/usb/dwc3/dwc3-qcom.c +2 -2
@@ -769,9 +769,9 @@ static int dwc3_qcom_probe(struct platform_device *pdev)
 
 		if (qcom->acpi_pdata->is_urs) {
 			qcom->urs_usb = dwc3_qcom_create_urs_usb_platdev(dev);
-			if (!qcom->urs_usb) {
+			if (IS_ERR_OR_NULL(qcom->urs_usb)) {
 				dev_err(dev, "failed to create URS USB platdev\n");
-				return -ENODEV;
+				return qcom->urs_usb ? PTR_ERR(qcom->urs_usb) : -ENODEV;

Please no ? : if at all possible. Spell it out as a real if statement.

thanks,

greg k-h

#2 lore raw

PATCH v2 1/1 usb: dwc3: qcom: Fix NULL vs IS_ERR checking in dwc3_qcom_probe

Since the acpi_create_platform_device() function may return error pointers, dwc3_qcom_create_urs_usb_platdev() function may return error pointers too. Using IS_ERR_OR_NULL() to check the return value to fix this.

Fixes c25c210f590e ("usb: dwc3: qcom: add URS Host support for sdm845 ACPI boot")
---
 drivers/usb/dwc3/dwc3-qcom.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
drivers/usb/dwc3/dwc3-qcom.c +5 -2
index 3cb01cdd02c2..b81a9e1c1315 100644
@@ -769,9 +769,12 @@ static int dwc3_qcom_probe(struct platform_device *pdev)
 
 		if (qcom->acpi_pdata->is_urs) {
 			qcom->urs_usb = dwc3_qcom_create_urs_usb_platdev(dev);
-			if (!qcom->urs_usb) {
+			if (IS_ERR_OR_NULL(qcom->urs_usb)) {
 				dev_err(dev, "failed to create URS USB platdev\n");
-				return -ENODEV;
+				if (!qcom->urs_usb)
+					return -ENODEV;
+				else
+					return PTR_ERR(qcom->urs_usb);
 			}
 		}
 	}
Signature · 1 line
2.17.1