]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
gpiolib: Fix scope-based gpio_device refcounting
authorLukas Wunner <lukas@wunner.de>
Mon, 15 Jan 2024 15:05:26 +0000 (16:05 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 25 Jan 2024 23:45:28 +0000 (15:45 -0800)
commit79e1bbfbff1f1ba07d60d22fd292442525e874d5
tree3dea86a5063c5fd195bd7878311e3eeb55b7fb74
parent768708af8d8f8b2f4d92a8be0486a948ef6baa3e
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 <lukas@wunner.de>
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
include/linux/gpio/driver.h