Skip to content

Commit 9cdabcb

Browse files
oneukumgregkh
authored andcommitted
usblp: fix race between disconnect() and read()
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>
1 parent 2923182 commit 9cdabcb

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

drivers/usb/class/usblp.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -827,6 +827,11 @@ static ssize_t usblp_read(struct file *file, char __user *buffer, size_t len, lo
827827
if (rv < 0)
828828
return rv;
829829

830+
if (!usblp->present) {
831+
count = -ENODEV;
832+
goto done;
833+
}
834+
830835
if ((avail = usblp->rstatus) < 0) {
831836
printk(KERN_ERR "usblp%d: error %d reading from printer\n",
832837
usblp->minor, (int)avail);

0 commit comments

Comments
 (0)