Revert "usb: yurex: Replace snprintf() with the safer scnprintf() variant"
commit 71c717cd8a2e180126932cc6851ff21c1d04d69a upstream. This reverts commit 86b20af11e84c26ae3fde4dcc4f490948e3f8035. This patch leads to passing 0 to simple_read_from_buffer() as a fifth argument, turning the read method into a nop. The change is fundamentally flawed, as it breaks the driver. Signed-off-by: Oliver Neukum <oneukum@suse.com> Cc: stable <stable@kernel.org> Link: https://lore.kernel.org/r/20241007094004.242122-1-oneukum@suse.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
afaec54239
commit
3ac86888fc
1 changed files with 8 additions and 11 deletions
|
|
@ -34,8 +34,6 @@
|
||||||
#define YUREX_BUF_SIZE 8
|
#define YUREX_BUF_SIZE 8
|
||||||
#define YUREX_WRITE_TIMEOUT (HZ*2)
|
#define YUREX_WRITE_TIMEOUT (HZ*2)
|
||||||
|
|
||||||
#define MAX_S64_STRLEN 20 /* {-}922337203685477580{7,8} */
|
|
||||||
|
|
||||||
/* table of devices that work with this driver */
|
/* table of devices that work with this driver */
|
||||||
static struct usb_device_id yurex_table[] = {
|
static struct usb_device_id yurex_table[] = {
|
||||||
{ USB_DEVICE(YUREX_VENDOR_ID, YUREX_PRODUCT_ID) },
|
{ USB_DEVICE(YUREX_VENDOR_ID, YUREX_PRODUCT_ID) },
|
||||||
|
|
@ -404,7 +402,8 @@ static ssize_t yurex_read(struct file *file, char __user *buffer, size_t count,
|
||||||
{
|
{
|
||||||
struct usb_yurex *dev;
|
struct usb_yurex *dev;
|
||||||
int len = 0;
|
int len = 0;
|
||||||
char in_buffer[MAX_S64_STRLEN];
|
char in_buffer[20];
|
||||||
|
unsigned long flags;
|
||||||
|
|
||||||
dev = file->private_data;
|
dev = file->private_data;
|
||||||
|
|
||||||
|
|
@ -414,16 +413,14 @@ static ssize_t yurex_read(struct file *file, char __user *buffer, size_t count,
|
||||||
return -ENODEV;
|
return -ENODEV;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (WARN_ON_ONCE(dev->bbu > S64_MAX || dev->bbu < S64_MIN)) {
|
spin_lock_irqsave(&dev->lock, flags);
|
||||||
mutex_unlock(&dev->io_mutex);
|
len = snprintf(in_buffer, 20, "%lld\n", dev->bbu);
|
||||||
return -EIO;
|
spin_unlock_irqrestore(&dev->lock, flags);
|
||||||
}
|
|
||||||
|
|
||||||
spin_lock_irq(&dev->lock);
|
|
||||||
scnprintf(in_buffer, MAX_S64_STRLEN, "%lld\n", dev->bbu);
|
|
||||||
spin_unlock_irq(&dev->lock);
|
|
||||||
mutex_unlock(&dev->io_mutex);
|
mutex_unlock(&dev->io_mutex);
|
||||||
|
|
||||||
|
if (WARN_ON_ONCE(len >= sizeof(in_buffer)))
|
||||||
|
return -EIO;
|
||||||
|
|
||||||
return simple_read_from_buffer(buffer, count, ppos, in_buffer, len);
|
return simple_read_from_buffer(buffer, count, ppos, in_buffer, len);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue