]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
gpio: cdev: Correct return code on memory allocation failure
authorTzung-Bi Shih <tzungbi@kernel.org>
Fri, 16 Jan 2026 08:10:18 +0000 (08:10 +0000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 30 Jan 2026 09:32:27 +0000 (10:32 +0100)
commit faff6846474e99295a139997f93ef6db222b5cee upstream.

-ENOMEM is a more appropriate return code for memory allocation
failures.  Correct it.

Cc: stable@vger.kernel.org
Fixes: 20bddcb40b2b ("gpiolib: cdev: replace locking wrappers for gpio_device with guards")
Signed-off-by: Tzung-Bi Shih <tzungbi@kernel.org>
Link: https://lore.kernel.org/r/20260116081036.352286-6-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 d925e75d1dce1078a2f43a39fb039041ab13f383..858110eda150eb0b6952f694dbdd0536c65cd595 100644 (file)
@@ -2720,7 +2720,7 @@ static int gpio_chrdev_open(struct inode *inode, struct file *file)
 
        cdev = kzalloc(sizeof(*cdev), GFP_KERNEL);
        if (!cdev)
-               return -ENODEV;
+               return -ENOMEM;
 
        cdev->watched_lines = bitmap_zalloc(gdev->ngpio, GFP_KERNEL);
        if (!cdev->watched_lines)