Revert "USB: misc: yurex: fix race between read and write"

This reverts commit 784d9ba932.
This commit is contained in:
Ksawlii 2024-11-24 00:23:14 +01:00
parent 26f3cb3d2d
commit 214c1427f7

View file

@ -403,6 +403,7 @@ static ssize_t yurex_read(struct file *file, char __user *buffer, size_t count,
struct usb_yurex *dev;
int len = 0;
char in_buffer[MAX_S64_STRLEN];
unsigned long flags;
dev = file->private_data;
@ -415,9 +416,9 @@ static ssize_t yurex_read(struct file *file, char __user *buffer, size_t count,
if (WARN_ON_ONCE(dev->bbu > S64_MAX || dev->bbu < S64_MIN))
return -EIO;
spin_lock_irq(&dev->lock);
spin_lock_irqsave(&dev->lock, flags);
scnprintf(in_buffer, MAX_S64_STRLEN, "%lld\n", dev->bbu);
spin_unlock_irq(&dev->lock);
spin_unlock_irqrestore(&dev->lock, flags);
mutex_unlock(&dev->io_mutex);
return simple_read_from_buffer(buffer, count, ppos, in_buffer, len);
@ -507,11 +508,8 @@ static ssize_t yurex_write(struct file *file, const char __user *user_buffer,
__func__, retval);
goto error;
}
if (set && timeout) {
spin_lock_irq(&dev->lock);
if (set && timeout)
dev->bbu = c2;
spin_unlock_irq(&dev->lock);
}
return timeout ? count : -EIO;
error: