On Tue, Mar 26, 2019 at 06:48:25PM +0100, Bartosz Golaszewski wrote: > wt., 26 mar 2019 o 16:21 Andy Shevchenko > <andriy.shevchenko@xxxxxxxxxxxxxxx> napisał(a): > > > > In case of debug and optional GPIO requested, the gpiod_put() is not aware of > > and will WARN, which is not the case. > > > > Make gpiod_put() NULL-aware to keep silent for optional GPIOs. > > > > Signed-off-by: Andy Shevchenko <andriy.shevchenko@xxxxxxxxxxxxxxx> > > --- > > drivers/gpio/gpiolib.c | 3 ++- > > 1 file changed, 2 insertions(+), 1 deletion(-) > > > > diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c > > index 144af0733581..36445e24ee89 100644 > > --- a/drivers/gpio/gpiolib.c > > +++ b/drivers/gpio/gpiolib.c > > @@ -4616,7 +4616,8 @@ EXPORT_SYMBOL_GPL(gpiod_get_array_optional); > > */ > > void gpiod_put(struct gpio_desc *desc) > > { > > - gpiod_free(desc); > > + if (desc) > > + gpiod_free(desc); > > } > > EXPORT_SYMBOL_GPL(gpiod_put); > > > > -- > > 2.20.1 > > > > In that case I don't think we need to keep checking desc for NULL in > gpiod_free(). I didn't remove the check there because it's called more than just from gpiod_put(). I didn't check all code paths myself. So, if it seems good for you to remove the check I can do it in next version. -- With Best Regards, Andy Shevchenko