projects/linux·commit 9cdabcb3

usblp: fix race between disconnect() and read()

9cdabcb3 · Oliver Neukum <[email protected]> · 2020-09-17 12:34:27 +02:00

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]>
Commit
9cdabcb3ef8c24ca3a456e4db7b012befb688e73
Parents
29231826

Changes

1 files changed · +5 −0

FileStatusAddDelContent
drivers/usb/class/usblp.cmodified+5−0View file

drivers/usb/class/usblp.c

View file
diff --git a/drivers/usb/class/usblp.c b/drivers/usb/class/usblp.c
index 084c48c..67cbd42 100644
--- a/drivers/usb/class/usblp.c
+++ b/drivers/usb/class/usblp.c
@@ -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);