On Wed, Dec 03, 2025 at 04:36:49PM +0100, Quentin Schulz wrote: > Hi François, > > On 12/2/25 7:39 PM, Francois Berder wrote: > > If func->pins could not be allocated, one must also free > > func variable that was allocated previously. > > > > Well.... devm_* functions should take care of this when the device is > removed (or probe failed), but if and only if CONFIG_DEVRES is enabled. > However, in that case, this code may be executed outside of a probe scenario > I guess (it is called in set_state() callback from the pinctrl device). This > thus makes sense to me here. > > Reviewed-by: Quentin Schulz <[email protected]> > > I'm also wondering if we shouldn't check the return value of > single_configure_pins/bits in set_state instead of always returning 0? > > We probably need to devm_kfree a bunch of other devm_ allocations as well? > > I see a loop in single_add_gpio_func() we should probably unwind if there's > a devm_kzalloc which fails? > > Maybe we need a .remove callback where we devm_kfree all of functions and > gpiofuncs lists from single_priv, in case DEVRES isn't actually set?
I've wondered, but not fired off a build to check, what the growth is going to be on default y for DEVRES. There's only a few platforms / chips doing it today and I think most drivers are written like the kernel where freeing is automatic, so there's lots of cases like this one here. -- Tom
signature.asc
Description: PGP signature

