From: Andy Shevchenko Date: Tue, 26 Mar 2019 15:21:14 +0000 (+0200) Subject: gpiolib: Don't WARN on gpiod_put() for optional GPIO X-Git-Url: http://git.lede-project.org./?a=commitdiff_plain;h=1d7765ba15aca68f3bc52f59434c1c34855bbb54;p=openwrt%2Fstaging%2Fblogic.git gpiolib: Don't WARN on gpiod_put() for optional GPIO 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 Signed-off-by: Bartosz Golaszewski --- 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);