[PATCH v2] fpga: altera-hps2fpga: Fix reset control leak

From: Xiangwu Lai

Date: Sat Nov 07 2026 - 10:38:37 EST


From: laixiangwu <laixiangwu@xxxxxxxxxxxxxxxxxxxx>

alt_fpga_bridge_probe() acquires the bridge reset control with
of_reset_control_get_exclusive_by_index(), which is not
device-managed. None of the probe error paths release it, and
alt_fpga_bridge_remove() does not call reset_control_put() either,
so the reset control reference leaks both on a failed probe and on
every bind/unbind cycle.

Since the leaked exclusive reset remains acquired, rebinding the
driver afterwards also fails with -EBUSY.

Use devm_reset_control_get_exclusive_by_index() so the reset control
is released automatically when the driver is unbound or the probe
fails.

Fixes: e5f8efa5c8bf ("ARM: socfpga: fpga bridge driver support")
Cc: stable@xxxxxxxxxxxxxxx
Signed-off-by: Xiangwu Lai <laixiangwu@xxxxxxxxxxxxxxxxxxxx>
---
Changes in v2:
- Drop the enumeration of probe error path examples from the commit
message, as suggested by Xu Yilun.
- Add Cc: stable@xxxxxxxxxxxxxxx for backporting.

Link: https://lore.kernel.org/r/20261103014240.1194-1-laixiangwu@xxxxxxxxxxxxxxxxxxxx
drivers/fpga/altera-hps2fpga.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/fpga/altera-hps2fpga.c b/drivers/fpga/altera-hps2fpga.c
index f2f125068..6d9798bb9 100644
--- a/drivers/fpga/altera-hps2fpga.c
+++ b/drivers/fpga/altera-hps2fpga.c
@@ -134,8 +134,7 @@ static int alt_fpga_bridge_probe(struct platform_device *pdev)

priv = (struct altera_hps2fpga_data *)device_get_match_data(dev);

- priv->bridge_reset = of_reset_control_get_exclusive_by_index(dev->of_node,
- 0);
+ priv->bridge_reset = devm_reset_control_get_exclusive_by_index(dev, 0);
if (IS_ERR(priv->bridge_reset)) {
dev_err(dev, "Could not get %s reset control\n", priv->name);
return PTR_ERR(priv->bridge_reset);
--
2.50.1.windows.1