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

From: Xu Yilun

Date: Sat Nov 07 2026 - 07:02:21 EST


On Tue, Nov 03, 2026 at 09:42:40AM +0800, Xiangwu Lai wrote:
> 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 (l3regs lookup
> failure, missing clock, clock enable failure, bridge registration
> failure)

Remove these examples, they are just noise that hurts reading.

> 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.
>
> 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 please

> Signed-off-by: Xiangwu Lai <laixiangwu@xxxxxxxxxxxxxxxxxxxx>

Otherwise it's a good fix. Looking forward a v2.

> ---
> 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);
>
>
>