Re: [PATCH] ata: libahci_platform: Fix device reference leak in ahci_platform_get_resources()
From: Damien Le Moal
Date: Tue Sep 15 2026 - 22:11:53 EST
On 2026/09/15 13:59, Wentao Liang wrote:
> of_find_device_by_node() takes a reference on the port platform device,
> which is only used to look up its port regulator and is never released,
> neither on success nor on the error paths. Drop the reference with
> put_device() once the regulator has been obtained, which covers both the
> success and error paths.
>
> Fixes: c7d7ddee7e24 ("ata: libahci: Allow using multiple regulators")
> Cc: stable@xxxxxxxxxxxxxxx
> Signed-off-by: Wentao Liang <vulab@xxxxxxxxxxx>
> ---
> drivers/ata/libahci_platform.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/drivers/ata/libahci_platform.c b/drivers/ata/libahci_platform.c
> index 6e072d681341..14a47e0bddd4 100644
> --- a/drivers/ata/libahci_platform.c
> +++ b/drivers/ata/libahci_platform.c
> @@ -624,6 +624,7 @@ struct ahci_host_priv *ahci_platform_get_resources(struct platform_device *pdev,
> if (port_dev) {
> rc = ahci_platform_get_regulator(hpriv, port,
> &port_dev->dev);
> + put_device(&port_dev->dev);
Looks good. But while at it, please remove the blank line between the call to
of_find_device_by_node() and the if.
With that done,
Reviewed-by: Damien Le Moal <dlemoal@xxxxxxxxxx>
> if (rc == -EPROBE_DEFER)
> goto err_out;
> }
--
Damien Le Moal
Western Digital Research