]> Git Repo - linux.git/commitdiff
usblp: fix race between disconnect() and read()
authorOliver Neukum <[email protected]>
Thu, 17 Sep 2020 10:34:27 +0000 (12:34 +0200)
committerGreg Kroah-Hartman <[email protected]>
Thu, 17 Sep 2020 16:45:30 +0000 (18:45 +0200)
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]>
drivers/usb/class/usblp.c

index 084c48c5848fc90354216254ffbd48c17a7be030..67cbd42421bee7e5776659a5f7ebfb077564a457 100644 (file)
@@ -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);
This page took 0.059961 seconds and 4 git commands to generate.