Skip to content

Commit

Permalink
usblp: fix race between disconnect() and read()
Browse files Browse the repository at this point in the history
read() needs to check whether the device has been
disconnected before it tries to talk to the device.

Signed-off-by: Oliver Neukum <[email protected]>
Reported-by: [email protected]
Link: https://lore.kernel.org/r/[email protected]
Cc: stable <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
  • Loading branch information
oneukum authored and gregkh committed Sep 17, 2020
1 parent 2923182 commit 9cdabcb
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions drivers/usb/class/usblp.c
Original file line number Diff line number Diff line change
Expand Up @@ -827,6 +827,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);
Expand Down

0 comments on commit 9cdabcb

Please sign in to comment.