ata: libahci_platform: Fix device reference leak in ahci_platform_get_resources()
Subsystems (3)
PATCH 1/1 ata: libahci_platform: Fix device reference leak in ahci_platform_get_resources()
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.
--- drivers/ata/libahci_platform.c | 1 + 1 file changed, 1 insertion(+)
drivers/ata/libahci_platform.c +1 -0
@@ -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; }
Signature · 1 line
2.34.1
Quoted 8 lines · Wentao Liang
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 withput_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
Niklas Cassel
maintainerQuoted 8 lines · Niklas Cassel
Quoted 7 lines · Wentao Liang
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 withput_device()once the regulator has been obtained, which covers both the success and error paths.
Quoted 6 lines
Quoted 1 line
[...]
Applied to libata/linux.git (for-7.3-fixes), thanks!
[1/1] ata:
libahci_platform: Fix device reference leak inahci_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
Quoted 18 lines · Wentao Liang
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 withput_device()once the regulator has been obtained, which covers both the success and error paths.Fixes c7d7ddee7e24 ("ata: libahci: Allow using multiple regulators")Signed-off-by Wentao Liang <[email protected]>--- drivers/ata/libahci_platform.c | 1 + 1 file changed, 1 insertion(+)drivers/ata/libahci_platform.c +0
-0
drivers/ata/libahci_platform.c struct ahci_host_priv *ahci_platform_get_resources(struct platform_device *pdev, · line 627
Quoted 4 lines
drivers/ata/libahci_platform.c +1
-0@@ -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,
Quoted 3 lines
drivers/ata/libahci_platform.c +0
-0if (rc == -EPROBE_DEFER ) goto err_out; }
Signature · 2 lines
Damien Le Moal Western Digital Research