Re: [PATCH v3] gpio: Fix resource leaks on errors in gpiochip_add_data_with_key()

From: Bartosz Golaszewski

Date: Fri Feb 27 2026 - 04:10:39 EST



On Thu, 05 Feb 2026 09:28:40 +0000, Tzung-Bi Shih wrote:
> Since commit aab5c6f20023 ("gpio: set device type for GPIO chips"),
> `gdev->dev.release` is unset. As a result, the reference count to
> `gdev->dev` isn't dropped on the error handling paths.
>
> Drop the reference on errors.
>
> Also reorder the instructions to make the error handling simpler.
> Now gpiochip_add_data_with_key() roughly looks like:
>
> [...]

Hi Tzung-Bi!

For now I queued this for v7.1. I want it to spend some time in linux-next as
I think it's a high-risk change. However, I preemptively put it into an
immutable branch - if all is good for three weeks or so, I'll send it upstream
for v7.0.

I see you added a Fixes tag dating back to 2024 and Cc'ed stable. I'm afraid
this change will not apply very far back, do you plan to backport it all the
way to v6.8?

[1/1] gpio: Fix resource leaks on errors in gpiochip_add_data_with_key()
https://git.kernel.org/brgl/c/16fdabe143fce2cbf89139677728e17e21b46c28

Best regards,
--
Bartosz Golaszewski <bartosz.golaszewski@xxxxxxxxxxxxxxxx>