linux-usb.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Vladimir Zapolskiy <vladimir.zapolskiy@linaro.org>
To: Miaoqian Lin <linmq006@gmail.com>
Cc: Andy Gross <agross@kernel.org>,
	Bjorn Andersson <bjorn.andersson@linaro.org>,
	Felipe Balbi <balbi@kernel.org>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	linux-arm-msm@vger.kernel.org, linux-usb@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] usb: dwc3: dwc3-qcom: Add missing platform_device_put() in dwc3_qcom_acpi_register_core
Date: Tue, 4 Jan 2022 22:10:33 +0200	[thread overview]
Message-ID: <83d55401-d8b3-f709-c77a-fa0e09fda27f@linaro.org> (raw)
In-Reply-To: <20211231113641.31474-1-linmq006@gmail.com>

On 12/31/21 1:36 PM, Miaoqian Lin wrote:
> 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")

> Signed-off-by: Miaoqian Lin <linmq006@gmail.com>
> ---
>   drivers/usb/dwc3/dwc3-qcom.c | 8 +++++++-
>   1 file changed, 7 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/usb/dwc3/dwc3-qcom.c b/drivers/usb/dwc3/dwc3-qcom.c
> index 3cb01cdd02c2..5257783f17b0 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)
> +	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.

> +	}
>   
>   	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.

> +	kfree(child_res);
> +	return 0;
>   
>   out:
> +	platform_device_put(qcom->dwc3);
>   	kfree(child_res);
>   	return ret;
>   }
> 

Reviewed-by: Vladimir Zapolskiy <vladimir.zapolskiy@linaro.org>

--
Best wishes,
Vladimir

  reply	other threads:[~2022-01-04 20:10 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 [this message]
2022-01-05  6:55   ` [PATCH v2] " Miaoqian Lin
2022-01-06 14:26     ` 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=83d55401-d8b3-f709-c77a-fa0e09fda27f@linaro.org \
    --to=vladimir.zapolskiy@linaro.org \
    --cc=agross@kernel.org \
    --cc=balbi@kernel.org \
    --cc=bjorn.andersson@linaro.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=linmq006@gmail.com \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.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;
as well as URLs for NNTP newsgroup(s).