]> git.itanic.dy.fi Git - linux-stable/commit
USB: usblp: fix a hang in poll() if disconnected
authorPete Zaitcev <zaitcev@redhat.com>
Thu, 4 Mar 2021 04:10:53 +0000 (22:10 -0600)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 17 Mar 2021 16:06:29 +0000 (17:06 +0100)
commit48c7fc4f14b654d522e5f15bafdc3ba7ba9c0ae3
tree60c1021cb4cb5ba928af8af19faadb60067de121
parentadb9639d1e500146e9cb7ed47e299ced023cf96c
USB: usblp: fix a hang in poll() if disconnected

commit 9de2c43acf37a17dc4c69ff78bb099b80fb74325 upstream.

Apparently an application that opens a device and calls select()
on it, will hang if the decice is disconnected. It's a little
surprising that we had this bug for 15 years, but apparently
nobody ever uses select() with a printer: only write() and read(),
and those work fine. Well, you can also select() with a timeout.

The fix is modeled after devio.c. A few other drivers check the
condition first, then do not add the wait queue in case the
device is disconnected. We doubt that's completely race-free.
So, this patch adds the process first, then locks properly
and checks for the disconnect.

Reviewed-by: Zqiang <qiang.zhang@windriver.com>
Signed-off-by: Pete Zaitcev <zaitcev@redhat.com>
Cc: stable <stable@vger.kernel.org>
Link: https://lore.kernel.org/r/20210303221053.1cf3313e@suzdal.zaitcev.lan
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/usb/class/usblp.c