Re: [PATCH] pinctrl: pinctrl-pic32: Fix resource leaks

From: Linus Walleij

Date: Fri Feb 27 2026 - 16:12:41 EST


On Fri, Feb 27, 2026 at 10:01 PM Ethan Tidmore <ethantidmore06@xxxxxxxxx> wrote:
> On Thu Feb 26, 2026 at 4:37 PM CST, Linus Walleij wrote:
>
> > Can't you just use devm_clk_get_enabled() and let devres do this?
>
> I thought about that but wasn't sure because I saw:
>
> ret = gpiochip_add_data(&bank->gpio_chip, bank);
>
> Later in the function and knew that you're not really suppose to mix
> manual resource allocation and devres.

And there is a bunch of other devm_* stuff before it so it's
confusing isn't it? A mix however you put it.

In this case that is just because the gpiochip_add_data() happens
last in probe().

If you study the driver you see it does not have a .remove() function
and you can bet your life no-one is manually testing to remove it,
so all the devm_* stuff is just there for exititing a failed or deferred
probe.

When the probe reaches gpiochip_add_data() that is the last
thing that can fail, and if it fails there are just all the other
resources that need to be free:ed.

I'm all for changing that to devm_gpiochip_add_data()
for completion but semanically it won't matter unless someone
goes in and unbinds the driver in sysfs.

So use devm_clk_get_enabled() and optionally convert
to devm_gpiochip_add_data() as well.

Yours,
Linus Walleij