]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
gpio: cdev: Fix resource leaks on errors in lineinfo_changed_notify()
authorTzung-Bi Shih <tzungbi@kernel.org>
Tue, 20 Jan 2026 03:08:56 +0000 (03:08 +0000)
committerBartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
Tue, 20 Jan 2026 08:52:31 +0000 (09:52 +0100)
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>
drivers/gpio/gpiolib-cdev.c

index 67cbb05d34ca07b98de0535dbf3fc4b7459c3f05..ed249a45d658b985dc179863dc3248ff37ec4597 100644 (file)
@@ -2549,6 +2549,7 @@ static int lineinfo_changed_notify(struct notifier_block *nb,
        ctx = kzalloc(sizeof(*ctx), GFP_ATOMIC);
        if (!ctx) {
                pr_err("Failed to allocate memory for line info notification\n");
+               fput(fp);
                return NOTIFY_DONE;
        }