Commit 2f77a557 authored by Harshit Mogalapalli's avatar Harshit Mogalapalli Committed by Wen Zhiwei
Browse files

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

stable inclusion
from stable-v6.6.54
commit e43caacf61101a962b9ba35c9d2b5c2628ec5eca
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/IAZ3K2

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=e43caacf61101a962b9ba35c9d2b5c2628ec5eca



--------------------------------

commit e7d3b9f28654dbfce7e09f8028210489adaf6a33 upstream.

Unlock before returning on the error path.

Fixes: 86b20af11e84 ("usb: yurex: Replace snprintf() with the safer scnprintf() variant")
Reported-by: default avatarDan Carpenter <error27@gmail.com>
Reported-by: default avatarkernel test robot <lkp@intel.com>
Closes: https://lore.kernel.org/r/202312170252.3udgrIcP-lkp@intel.com/


Signed-off-by: default avatarHarshit Mogalapalli <harshit.m.mogalapalli@oracle.com>
Link: https://lore.kernel.org/r/20231219063639.450994-1-harshit.m.mogalapalli@oracle.com


Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: default avatarWen Zhiwei <wenzhiwei@kylinos.cn>
parent 585128b7
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -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);