Skip to contentSkip to conversation

usb: dwc3: dwc3-qcom: Add missing platform_device_put() in dwc3_qcom_acpi_register_core

PATCH Superseded Miaoqian Lin 3 participants 6 messages Dec 31, 2021 – Jan 7, 2022

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

PATCH 1/1 usb: dwc3: dwc3-qcom: Add missing platform_device_put() in dwc3_qcom_acpi_register_core

Add the missing platform_device_put() before return from dwc3_qcom_acpi_register_core in the error handling case.

---
 drivers/usb/dwc3/dwc3-qcom.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
drivers/usb/dwc3/dwc3-qcom.c +7 -1
index 3cb01cdd02c2..5257783f17b0 100644
@@ -598,8 +598,10 @@ static int dwc3_qcom_acpi_register_core(struct platform_device *pdev)
 	qcom->dwc3->dev.coherent_dma_mask = dev->coherent_dma_mask;
 
 	child_res = kcalloc(2, sizeof(*child_res), GFP_KERNEL);
-	if (!child_res)
+	if (!child_res) {
+		platform_device_put(qcom->dwc3);
 		return -ENOMEM;
+	}
 
 	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
 	if (!res) {
@@ -637,9 +639,13 @@ static int dwc3_qcom_acpi_register_core(struct platform_device *pdev)
 	if (ret) {
 		dev_err(&pdev->dev, "failed to add device\n");
 		device_remove_software_node(&qcom->dwc3->dev);
+		goto out;
 	}
+	kfree(child_res);
+	return 0;
 
 out:
+	platform_device_put(qcom->dwc3);
 	kfree(child_res);
 	return ret;
 }
Signature · 1 line
2.17.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 3 lines · Miaoqian Lin

Add the missing platform_device_put() before return from dwc3_qcom_acpi_register_core in the error handling case.

The discovered issue is valid.

Fixes 2bc02355f8ba ("usb: dwc3: qcom: Add support for booting with ACPI")
Quoted 10 lines
---
  drivers/usb/dwc3/dwc3-qcom.c | 8 +++++++-
  1 file changed, 7 insertions(+), 1 deletion(-)
drivers/usb/dwc3/dwc3-qcom.c +0 -0
index 3cb01cdd02c2..5257783f17b0 100644

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

Quoted 7 lines
drivers/usb/dwc3/dwc3-qcom.c +2 -1
@@ -598,8 +598,10 @@ static int dwc3_qcom_acpi_register_core(struct platform_device *pdev)
  	qcom->dwc3->dev.coherent_dma_mask = dev->coherent_dma_mask;
 
  	child_res = kcalloc(2, sizeof(*child_res), GFP_KERNEL);
-	if (!child_res)
+	if (!child_res) {
+		platform_device_put(qcom->dwc3);
  		return -ENOMEM;

Please do it in a unified way along all checks:

		ret = -ENOMEM;
		goto out;

kfree(NULL) is legit, please utilize it.

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

Quoted 10 lines
drivers/usb/dwc3/dwc3-qcom.c +2 -0
+	}
 
  	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
  	if (!res) {
@@ -637,9 +639,13 @@ static int dwc3_qcom_acpi_register_core(struct platform_device *pdev)
  	if (ret) {
  		dev_err(&pdev->dev, "failed to add device\n");
  		device_remove_software_node(&qcom->dwc3->dev);
+		goto out;
  	}

Please add a blank line here after the closing curly bracket.

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

Quoted 9 lines
drivers/usb/dwc3/dwc3-qcom.c +3 -0
+	kfree(child_res);
+	return 0;
 
  out:
+	platform_device_put(qcom->dwc3);
  	kfree(child_res);
  	return ret;
  }

--
Best wishes,
Vladimir

#2 lore raw

PATCH v2 1/1 usb: dwc3: dwc3-qcom: Add missing platform_device_put() in dwc3_qcom_acpi_register_core

Fix the missing platform_device_put() before return from dwc3_qcom_acpi_register_core in the error handling case.

Fixes 2bc02355f8ba ("usb: dwc3: qcom: Add support for booting with ACPI")

---
Changes in v2:
- add fixes tag.
- do error handling in a unified way.
- add necessary blank line.

---
 drivers/usb/dwc3/dwc3-qcom.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)
drivers/usb/dwc3/dwc3-qcom.c +9 -2
index 3cb01cdd02c2..f7f4af4c4ce5 100644
@@ -598,8 +598,10 @@ static int dwc3_qcom_acpi_register_core(struct platform_device *pdev)
 	qcom->dwc3->dev.coherent_dma_mask = dev->coherent_dma_mask;
 
 	child_res = kcalloc(2, sizeof(*child_res), GFP_KERNEL);
-	if (!child_res)
-		return -ENOMEM;
+	if (!child_res) {
+		ret = -ENOMEM;
+		goto out;
+	}
 
 	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
 	if (!res) {
@@ -637,9 +639,14 @@ static int dwc3_qcom_acpi_register_core(struct platform_device *pdev)
 	if (ret) {
 		dev_err(&pdev->dev, "failed to add device\n");
 		device_remove_software_node(&qcom->dwc3->dev);
+		goto out;
 	}
 
+	kfree(child_res);
+	return 0;
+
 out:
+	platform_device_put(qcom->dwc3);
 	kfree(child_res);
 	return ret;
 }
Signature · 1 line
2.17.1
maintainer
#3 lore raw
Quoted 5 lines · Miaoqian Lin

Fix the missing platform_device_put() before return from dwc3_qcom_acpi_register_core in the error handling case.

Fixes 2bc02355f8ba ("usb: dwc3: qcom: Add support for booting with ACPI")
Quoted 8 lines

---
Changes in v2:
- add fixes tag.
- do error handling in a unified way.
- add necessary blank line.

---
 drivers/usb/dwc3/dwc3-qcom.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

Does not apply to my tree at all :(

Please rebase and resend.

thanks,

greg k-h

#4 lore raw

Hi greg k-h:

Quoted 12 lines
Quoted 10 lines
Fixes 2bc02355f8ba ("usb: dwc3: qcom: Add support for booting with ACPI")

---
Changes in v2:
- add fixes tag.
- do error handling in a unified way.
- add necessary blank line.

---
 drivers/usb/dwc3/dwc3-qcom.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)
Quoted 3 lines

Does not apply to my tree at all :(

Please rebase and resend.

I see the v1 of this patch has been applied to usb-next branch.
v2 has some format fixes. I am unsure should I rebase v2 on the top of usb-next? I am afraid to introduce more inconvenience.

Regards,
Miaoqian.

maintainer
#5 lore raw
Quoted 13 lines · Miaoqian Lin

Hi greg k-h:

Quoted 12 lines
Quoted 10 lines
Fixes 2bc02355f8ba ("usb: dwc3: qcom: Add support for booting with ACPI")

---
Changes in v2:
- add fixes tag.
- do error handling in a unified way.
- add necessary blank line.

---
 drivers/usb/dwc3/dwc3-qcom.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)
Quoted 7 lines
Quoted 3 lines

Does not apply to my tree at all :(

Please rebase and resend.

I see the v1 of this patch has been applied to usb-next branch.
v2 has some format fixes. I am unsure should I rebase v2 on the top of usb-next? I am afraid to introduce more inconvenience.

If v1 was incorrect, please submit a patch to either fix it, or revert it entirely.

thanks,

greg k-h