Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

usb: yurex: Fix inconsistent locking bug in yurex_read()

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>

authored by

Harshit Mogalapalli and committed by
Greg Kroah-Hartman
e7d3b9f2 4c3ea81a

+3 -1
+3 -1
drivers/usb/misc/yurex.c
··· 414 414 return -ENODEV; 415 415 } 416 416 417 - if (WARN_ON_ONCE(dev->bbu > S64_MAX || dev->bbu < S64_MIN)) 417 + if (WARN_ON_ONCE(dev->bbu > S64_MAX || dev->bbu < S64_MIN)) { 418 + mutex_unlock(&dev->io_mutex); 418 419 return -EIO; 420 + } 419 421 420 422 spin_lock_irqsave(&dev->lock, flags); 421 423 scnprintf(in_buffer, MAX_S64_STRLEN, "%lld\n", dev->bbu);