]> git.ipfire.org Git - thirdparty/kernel/stable.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)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 30 Jan 2026 09:32:27 +0000 (10:32 +0100)
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

index 858110eda150eb0b6952f694dbdd0536c65cd595..dadd4682a3b5296b06a2e57dbf545119959fab4e 100644 (file)
@@ -2573,6 +2573,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;
        }