Re: [PATCH] ata: pata_ep93xx: fix double-free of DMA channel on error path

[email protected] Wed, 08 Jul 2026 09:35:16 +0000
Newsgroups gmane.linux.ide
Message-ID <[email protected]>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:

Pre-existing issues:
- [High] Probe fails entirely instead of falling back to PIO mode when DMA channels are not available.
--

--- Patch [1]: [PATCH] ata: pata_ep93xx: fix double-free of DMA channel on error path ---
commit 5d77ddcea9fce813ec9dad68a5d5fe3f97dacb61
Author: Chen Changcheng <[email protected]>

ata: pata_ep93xx: fix double-free of DMA channel on error path

This commit fixes a double-free of the rx DMA channel and a potential invalid
release of an ERR_PTR tx channel in the ep93xx_pata_dma_init() error path.
It achieves this by updating ep93xx_pata_release_dma() to safely check using
IS_ERR_OR_NULL() and adjusting the error jump labels.

> diff --git a/drivers/ata/pata_ep93xx.c b/drivers/ata/pata_ep93xx.c
> index 42a24dc51d26b..b4fb89481b7ee 100644
> --- a/drivers/ata/pata_ep93xx.c
> +++ b/drivers/ata/pata_ep93xx.c
[ ... ]
> @@ -664,7 +664,7 @@ static int ep93xx_pata_dma_init(struct ep93xx_pata_data *drv_data)
>  	if (IS_ERR(drv_data->dma_tx_channel)) {
>  		ret = dev_err_probe(dev, PTR_ERR(drv_data->dma_tx_channel),
>  				    "tx DMA setup failed\n");
> -		goto fail_release_rx;
> +		goto fail_release_dma;

[Severity: High]
This is a pre-existing issue, but does this error path prevent the driver
from falling back to PIO mode?

In ep93xx_pata_probe(), the driver aborts entirely if ep93xx_pata_dma_init()
returns an error:

ep93xx_pata_probe() {
    ...
    err = ep93xx_pata_dma_init(drv_data);
    if (err)
        return err;
    ...
}

If dma_request_chan() returns an error (like -ENODEV when DMA is not
configured in the Device Tree), the error is propagated via dev_err_probe().

Would it be better to treat missing DMA channels as a soft failure so the
device can still initialize and operate in PIO mode?

>  	}
>  
>  	/* Configure receive channel direction and source address */

-- 
Sashiko AI review ยท https://sashiko.dev/#/patchset/[email protected]?part=1