From: Harshit Mogalapalli Date: Tue, 19 Dec 2023 06:36:35 +0000 (-0800) Subject: usb: yurex: Fix inconsistent locking bug in yurex_read() X-Git-Tag: v5.10.227~256 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=767b71f2920780e4a2cbf8298f5cc58da875ba81;p=thirdparty%2Fkernel%2Fstable.git usb: yurex: Fix inconsistent locking bug in yurex_read() 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 Reported-by: kernel test robot Closes: https://lore.kernel.org/r/202312170252.3udgrIcP-lkp@intel.com/ Signed-off-by: Harshit Mogalapalli Link: https://lore.kernel.org/r/20231219063639.450994-1-harshit.m.mogalapalli@oracle.com Signed-off-by: Greg Kroah-Hartman --- diff --git a/drivers/usb/misc/yurex.c b/drivers/usb/misc/yurex.c index 494db0178c1e1..4eb30089dddf9 100644 --- a/drivers/usb/misc/yurex.c +++ b/drivers/usb/misc/yurex.c @@ -412,8 +412,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);