diff options
author | Oliver Neukum <oneukum@suse.com> | 2020-09-17 12:34:27 +0200 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2020-09-23 08:46:16 +0200 |
commit | 11ecdfc83ae28feef098ec26cf7e1cbe4a65175d (patch) | |
tree | a0cb18b5f275caac458375da2137142a13e2cc50 /drivers/usb | |
parent | e7fdd0203890900dc2ccb261838024cd6d8daa29 (diff) | |
download | linux-stable-11ecdfc83ae28feef098ec26cf7e1cbe4a65175d.tar.gz linux-stable-11ecdfc83ae28feef098ec26cf7e1cbe4a65175d.tar.bz2 linux-stable-11ecdfc83ae28feef098ec26cf7e1cbe4a65175d.zip |
usblp: fix race between disconnect() and read()
commit 9cdabcb3ef8c24ca3a456e4db7b012befb688e73 upstream.
read() needs to check whether the device has been
disconnected before it tries to talk to the device.
Signed-off-by: Oliver Neukum <oneukum@suse.com>
Reported-by: syzbot+be5b5f86a162a6c281e6@syzkaller.appspotmail.com
Link: https://lore.kernel.org/r/20200917103427.15740-1-oneukum@suse.com
Cc: stable <stable@vger.kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/usb')
-rw-r--r-- | drivers/usb/class/usblp.c | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/drivers/usb/class/usblp.c b/drivers/usb/class/usblp.c index c578d64edc15..71c2ae4b8106 100644 --- a/drivers/usb/class/usblp.c +++ b/drivers/usb/class/usblp.c @@ -840,6 +840,11 @@ static ssize_t usblp_read(struct file *file, char __user *buffer, size_t len, lo if (rv < 0) return rv; + if (!usblp->present) { + count = -ENODEV; + goto done; + } + if ((avail = usblp->rstatus) < 0) { printk(KERN_ERR "usblp%d: error %d reading from printer\n", usblp->minor, (int)avail); |