Skip to contentSkip to conversation

patch "usblp: fix race between disconnect() and read()" added to usb-linus

PATCH [email protected] 1 participant 1 message Sep 17, 2020

Subsystems (3)
lore
Share & tools
lore

[email protected]

author maintainer Applied
#0 lore raw

This is a note to let you know that I've just added the patch titled

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

to my usb git tree which can be found at
git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb.git
in the usb-linus branch.

The patch will show up in the next release of the linux-next tree (usually sometime within the next 24 hours during the week.)

The patch will hopefully also be merged in Linus's tree for the next -rc kernel release.

If you have any questions about this process, please let me know.

From 9cdabcb3ef8c24ca3a456e4db7b012befb688e73 Mon Sep 17 00:00:00 2001
From: Oliver Neukum <[email protected]>
Date: Thu, 17 Sep 2020 12:34:27 +0200
Subject: 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.

---
 drivers/usb/class/usblp.c | 5 +++++
 1 file changed, 5 insertions(+)
drivers/usb/class/usblp.c +5 -0
index 084c48c5848f..67cbd42421be 100644
@@ -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);
Signature · 1 line
2.28.0