[PATCH 6.18 217/227] gpio: cdev: Fix resource leaks on errors in lineinfo_changed_notify()

Greg Kroah-Hartman
2026-01-28T16:02:15Z

From: Tzung-Bi Shih <tzungbi@kernel.org>

commit 70b3c280533167749a8f740acaa8ef720f78f984 upstream.

On error handling paths, lineinfo_changed_notify() doesn't free the
allocated resources which results leaks. Fix it.

Cc: stable@vger.kernel.org
Fixes: d4cd0902c156 ("gpio: cdev: make sure the cdev fd is still active before emitting events")
Signed-off-by: Tzung-Bi Shih <tzungbi@kernel.org>
Link: https://lore.kernel.org/r/20260120030857.2144847-1-tzungbi@kernel.org
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
drivers/gpio/gpiolib-cdev.c | 1 +
1 file changed, 1 insertion(+)

--- a/drivers/gpio/gpiolib-cdev.c
+++ b/drivers/gpio/gpiolib-cdev.c
@@ -2573,6 +2573,7 @@ static int lineinfo_changed_notify(struc
ctx = kzalloc(sizeof(*ctx), GFP_ATOMIC);
if (!ctx) {
pr_err("Failed to allocate memory for line info notification\n");
+ fput(fp);
return NOTIFY_DONE;
}