]> git.itanic.dy.fi Git - linux-stable/commitdiff
gpiolib: Fix scope-based gpio_device refcounting
authorLukas Wunner <lukas@wunner.de>
Mon, 15 Jan 2024 15:05:26 +0000 (16:05 +0100)
committerBartosz Golaszewski <bartosz.golaszewski@linaro.org>
Mon, 15 Jan 2024 17:41:29 +0000 (18:41 +0100)
Commit 9e4555d1e54a ("gpiolib: add support for scope-based management to
gpio_device") sought to add scope-based gpio_device refcounting, but
erroneously forgot a negation of IS_ERR_OR_NULL().

As a result, gpio_device_put() is not called if the gpio_device pointer
is valid (meaning the ref is leaked), but only called if the pointer is
NULL or an ERR_PTR().

While at it drop a superfluous trailing semicolon.

Fixes: 9e4555d1e54a ("gpiolib: add support for scope-based management to gpio_device")
Signed-off-by: Lukas Wunner <lukas@wunner.de>
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
include/linux/gpio/driver.h

index e846bd4e7559bb54bba7ffb2dcda3dc8e0099e16..9a5c6c76e6533385dbb32de98abfd330c8736585 100644 (file)
@@ -635,7 +635,7 @@ struct gpio_device *gpio_device_get(struct gpio_device *gdev);
 void gpio_device_put(struct gpio_device *gdev);
 
 DEFINE_FREE(gpio_device_put, struct gpio_device *,
-           if (IS_ERR_OR_NULL(_T)) gpio_device_put(_T));
+           if (!IS_ERR_OR_NULL(_T)) gpio_device_put(_T))
 
 struct device *gpio_device_to_device(struct gpio_device *gdev);