mirror of
https://github.com/torvalds/linux.git
synced 2025-12-07 20:06:24 +00:00
usb: chaoskey: fix locking for O_NONBLOCK
A failure to take a lock with O_NONBLOCK needs to result
in -EAGAIN. Change it.
Fixes: 66e3e59189 ("usb: Add driver for Altus Metrum ChaosKey device (v2)")
Signed-off-by: Oliver Neukum <oneukum@suse.com>
Link: https://patch.msgid.link/20251030093918.2248104-1-oneukum@suse.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
7ebbd0a5a9
commit
a2fa8a12e6
@@ -444,9 +444,19 @@ static ssize_t chaoskey_read(struct file *file,
|
||||
goto bail;
|
||||
mutex_unlock(&dev->rng_lock);
|
||||
|
||||
result = mutex_lock_interruptible(&dev->lock);
|
||||
if (result)
|
||||
goto bail;
|
||||
if (file->f_flags & O_NONBLOCK) {
|
||||
result = mutex_trylock(&dev->lock);
|
||||
if (result == 0) {
|
||||
result = -EAGAIN;
|
||||
goto bail;
|
||||
} else {
|
||||
result = 0;
|
||||
}
|
||||
} else {
|
||||
result = mutex_lock_interruptible(&dev->lock);
|
||||
if (result)
|
||||
goto bail;
|
||||
}
|
||||
if (dev->valid == dev->used) {
|
||||
result = _chaoskey_fill(dev);
|
||||
if (result < 0) {
|
||||
|
||||
Reference in New Issue
Block a user