From: Lukas Wunner Date: Mon, 15 Jan 2024 15:05:26 +0000 (+0100) Subject: gpiolib: Fix scope-based gpio_device refcounting X-Git-Tag: v6.7.2~36 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=79e1bbfbff1f1ba07d60d22fd292442525e874d5;p=thirdparty%2Fkernel%2Fstable.git gpiolib: Fix scope-based gpio_device refcounting [ Upstream commit 832b371097eb928d077c827b8f117bf5b99d35c0 ] 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 Signed-off-by: Bartosz Golaszewski Signed-off-by: Sasha Levin --- diff --git a/include/linux/gpio/driver.h b/include/linux/gpio/driver.h index 0aed62f0c6330..f2878b3614634 100644 --- a/include/linux/gpio/driver.h +++ b/include/linux/gpio/driver.h @@ -614,7 +614,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);