]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
usb: yurex: Fix inconsistent locking bug in yurex_read()
authorHarshit Mogalapalli <harshit.m.mogalapalli@oracle.com>
Tue, 19 Dec 2023 06:36:35 +0000 (22:36 -0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 4 Oct 2024 14:30:04 +0000 (16:30 +0200)
commit e7d3b9f28654dbfce7e09f8028210489adaf6a33 upstream.

Unlock before returning on the error path.

Fixes: 86b20af11e84 ("usb: yurex: Replace snprintf() with the safer scnprintf() variant")
Reported-by: Dan Carpenter <error27@gmail.com>
Reported-by: kernel test robot <lkp@intel.com>
Closes: https://lore.kernel.org/r/202312170252.3udgrIcP-lkp@intel.com/
Signed-off-by: Harshit Mogalapalli <harshit.m.mogalapalli@oracle.com>
Link: https://lore.kernel.org/r/20231219063639.450994-1-harshit.m.mogalapalli@oracle.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/usb/misc/yurex.c

index 44136989f6c6a29a1a8f9d7b623e41b01ad923f8..6adaaf66c14d7bedad50c3c2dd85ec068194e737 100644 (file)
@@ -413,8 +413,10 @@ static ssize_t yurex_read(struct file *file, char __user *buffer, size_t count,
                return -ENODEV;
        }
 
-       if (WARN_ON_ONCE(dev->bbu > S64_MAX || dev->bbu < S64_MIN))
+       if (WARN_ON_ONCE(dev->bbu > S64_MAX || dev->bbu < S64_MIN)) {
+               mutex_unlock(&dev->io_mutex);
                return -EIO;
+       }
 
        spin_lock_irq(&dev->lock);
        scnprintf(in_buffer, MAX_S64_STRLEN, "%lld\n", dev->bbu);