mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] ata: libahci_platform: Fix device reference leak in ahci_platform_get_resources()
@ 2026-09-15  6:59 Wentao Liang
  2026-09-15  9:22 ` Niklas Cassel
  2026-09-16  2:11 ` Damien Le Moal
  0 siblings, 2 replies; 4+ messages in thread
From: Wentao Liang @ 2026-09-15  6:59 UTC (permalink / raw)
  To: cassel
  Cc: dlemoal, gregory.clement, hansg, linux-ide, linux-kernel, tj,
	Wentao Liang, stable

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@vger.kernel.org
Signed-off-by: Wentao Liang <vulab@iscas.ac.cn>
---
 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);
 				if (rc == -EPROBE_DEFER)
 					goto err_out;
 			}
-- 
2.34.1


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] ata: libahci_platform: Fix device reference leak in ahci_platform_get_resources()
  2026-09-15  6:59 [PATCH] ata: libahci_platform: Fix device reference leak in ahci_platform_get_resources() Wentao Liang
@ 2026-09-15  9:22 ` Niklas Cassel
  2026-09-16  5:29   ` Niklas Cassel
  2026-09-16  2:11 ` Damien Le Moal
  1 sibling, 1 reply; 4+ messages in thread
From: Niklas Cassel @ 2026-09-15  9:22 UTC (permalink / raw)
  To: Wentao Liang
  Cc: dlemoal, gregory.clement, hansg, linux-ide, linux-kernel, tj, stable

On Tue, 15 Sep 2026 06:59:33 +0000, 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.
> 
> 
> [...]

Applied to libata/linux.git (for-7.3-fixes), thanks!

[1/1] ata: libahci_platform: Fix device reference leak in ahci_platform_get_resources()
      https://git.kernel.org/libata/linux/c/26ca58db

Kind regards,
Niklas


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] ata: libahci_platform: Fix device reference leak in ahci_platform_get_resources()
  2026-09-15  6:59 [PATCH] ata: libahci_platform: Fix device reference leak in ahci_platform_get_resources() Wentao Liang
  2026-09-15  9:22 ` Niklas Cassel
@ 2026-09-16  2:11 ` Damien Le Moal
  1 sibling, 0 replies; 4+ messages in thread
From: Damien Le Moal @ 2026-09-16  2:11 UTC (permalink / raw)
  To: Wentao Liang, cassel
  Cc: gregory.clement, hansg, linux-ide, linux-kernel, tj, stable

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@vger.kernel.org
> Signed-off-by: Wentao Liang <vulab@iscas.ac.cn>
> ---
>  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@kernel.org>


>  				if (rc == -EPROBE_DEFER)
>  					goto err_out;
>  			}


-- 
Damien Le Moal
Western Digital Research

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] ata: libahci_platform: Fix device reference leak in ahci_platform_get_resources()
  2026-09-15  9:22 ` Niklas Cassel
@ 2026-09-16  5:29   ` Niklas Cassel
  0 siblings, 0 replies; 4+ messages in thread
From: Niklas Cassel @ 2026-09-16  5:29 UTC (permalink / raw)
  To: Wentao Liang
  Cc: dlemoal, gregory.clement, hansg, linux-ide, linux-kernel, tj, stable

On Tue, Sep 15, 2026 at 11:22:11AM +0200, Niklas Cassel wrote:
> On Tue, 15 Sep 2026 06:59:33 +0000, 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.
> > 
> > 
> > [...]
> 
> Applied to libata/linux.git (for-7.3-fixes), thanks!
> 
> [1/1] ata: libahci_platform: Fix device reference leak in ahci_platform_get_resources()
>       https://git.kernel.org/libata/linux/c/26ca58db

Wentao,

Since your commit was top of tree, I took the liberty to amend your commit
to address Damien's review comment and to pick up his R-b tag, new SHA1:

https://git.kernel.org/libata/linux/c/0d1cb833


Kind regards,
Niklas

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2026-09-16  5:29 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-09-15  6:59 [PATCH] ata: libahci_platform: Fix device reference leak in ahci_platform_get_resources() Wentao Liang
2026-09-15  9:22 ` Niklas Cassel
2026-09-16  5:29   ` Niklas Cassel
2026-09-16  2:11 ` Damien Le Moal

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®