Re: [PATCH v3 1/2] usb: chipidea: ci_hdrc_imx: Propagate errors from optional IRQ lookup

[email protected]
Newsgroups dev.linux.lists.imx
Message-ID <[email protected]>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:

Pre-existing issues:
- [High] If `devm_kasprintf()` fails to allocate memory for `irq_name`, `dev_err_probe()` is called but its return value is not assigned to `ret`. Since `ret` is `0` at this point, the probe function incorrectly returns `0` (success) despite the failure, leaving the device in a broken, partially initialized state.
--

--- Patch [1]: [PATCH v3 1/2] usb: chipidea: ci_hdrc_imx: Propagate errors from optional IRQ lookup ---
commit bd6ce4edd163bb35e7e3be5ae05ae52d0c380e8a
Author: bui duc phuc <[email protected]>

usb: chipidea: ci_hdrc_imx: Propagate errors from optional IRQ lookup

This commit updates ci_hdrc_imx_probe() to propagate errors returned from
platform_get_irq_optional(). Instead of continuing without an IRQ on
failures like -EPROBE_DEFER or -EINVAL, the driver now properly aborts
and returns the error.

> diff --git a/drivers/usb/chipidea/ci_hdrc_imx.c b/drivers/usb/chipidea/ci_hdrc_imx.c
> index 56d2ba824a0b2..9e529398c6075 100644
> --- a/drivers/usb/chipidea/ci_hdrc_imx.c
> +++ b/drivers/usb/chipidea/ci_hdrc_imx.c
> @@ -525,6 +525,10 @@ static int ci_hdrc_imx_probe(struct platform_device *pdev)
>  		data->supports_runtime_pm = true;
>  
>  	data->wakeup_irq = platform_get_irq_optional(pdev, 1);
> +	if (data->wakeup_irq < 0 && data->wakeup_irq != -ENXIO) {
> +		ret = data->wakeup_irq;
> +		goto phy_shutdown;
> +	}
>  	if (data->wakeup_irq > 0) {
>  		irq_name = devm_kasprintf(dev, GFP_KERNEL, "%s:wakeup", pdata.name);
>  		if (!irq_name) {

[Severity: High]
This is a pre-existing issue, but missing an assignment to ret here causes
the probe to falsely succeed:

drivers/usb/chipidea/ci_hdrc_imx.c:ci_hdrc_imx_probe() {
    ...
	if (data->wakeup_irq > 0) {
		irq_name = devm_kasprintf(dev, GFP_KERNEL, "%s:wakeup", pdata.name);
		if (!irq_name) {
			dev_err_probe(dev, -ENOMEM, "failed to create irq_name\n");
			goto err_clk;
		}
    ...
}

Because dev_err_probe() is called but its return value is not assigned to
ret, and ret is 0 at this point, the probe function incorrectly returns 0
(success) despite the memory allocation failure.

Does this code need to assign the error to ret before jumping to err_clk?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.