public inbox for linux-arm-msm@vger.kernel.org
 help / color / mirror / Atom feed
From: Miaoqian Lin <linmq006@gmail.com>
To: vladimir.zapolskiy@linaro.org
Cc: agross@kernel.org, balbi@kernel.org, bjorn.andersson@linaro.org,
	gregkh@linuxfoundation.org, linmq006@gmail.com,
	linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-usb@vger.kernel.org
Subject: [PATCH v2] usb: dwc3: dwc3-qcom: Add missing platform_device_put() in dwc3_qcom_acpi_register_core
Date: Wed,  5 Jan 2022 06:55:17 +0000	[thread overview]
Message-ID: <20220105065517.6967-1-linmq006@gmail.com> (raw)
In-Reply-To: <83d55401-d8b3-f709-c77a-fa0e09fda27f@linaro.org>

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")
Signed-off-by: Miaoqian Lin <linmq006@gmail.com>
---
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(-)

diff --git a/drivers/usb/dwc3/dwc3-qcom.c b/drivers/usb/dwc3/dwc3-qcom.c
index 3cb01cdd02c2..f7f4af4c4ce5 100644
--- a/drivers/usb/dwc3/dwc3-qcom.c
+++ b/drivers/usb/dwc3/dwc3-qcom.c
@@ -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;
 }
-- 
2.17.1


  reply	other threads:[~2022-01-05  6:55 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-31 11:36 [PATCH] usb: dwc3: dwc3-qcom: Add missing platform_device_put() in dwc3_qcom_acpi_register_core Miaoqian Lin
2022-01-04 20:10 ` Vladimir Zapolskiy
2022-01-05  6:55   ` Miaoqian Lin [this message]
2022-01-06 14:26     ` [PATCH v2] " Greg KH
2022-01-07  3:07       ` Miaoqian Lin
2022-01-07  9:04         ` Greg KH

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220105065517.6967-1-linmq006@gmail.com \
    --to=linmq006@gmail.com \
    --cc=agross@kernel.org \
    --cc=balbi@kernel.org \
    --cc=bjorn.andersson@linaro.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=vladimir.zapolskiy@linaro.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox