lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <83d55401-d8b3-f709-c77a-fa0e09fda27f@linaro.org>
Date:   Tue, 4 Jan 2022 22:10:33 +0200
From:   Vladimir Zapolskiy <vladimir.zapolskiy@...aro.org>
To:     Miaoqian Lin <linmq006@...il.com>
Cc:     Andy Gross <agross@...nel.org>,
        Bjorn Andersson <bjorn.andersson@...aro.org>,
        Felipe Balbi <balbi@...nel.org>,
        Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
        linux-arm-msm@...r.kernel.org, linux-usb@...r.kernel.org,
        linux-kernel@...r.kernel.org
Subject: Re: [PATCH] usb: dwc3: dwc3-qcom: Add missing platform_device_put()
 in dwc3_qcom_acpi_register_core

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@...il.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@...aro.org>

--
Best wishes,
Vladimir

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ