From zaitcev@redhat.com Tue Aug 14 22:15:05 2007 From: Pete Zaitcev Date: Mon, 13 Aug 2007 22:50:13 -0700 Subject: usblp: mutex in usblp_check_status To: greg@kroah.com Cc: linux-usb-devel@lists.sourceforge.net, zaitcev@redhat.com Message-ID: <20070813225013.68bae471.zaitcev@redhat.com> Add a mutex to protect the ->statusbuf. Not really an issue, because CUPS is single-threaded when it talks to the printer, but I feel safer this way. This should be deadlock-free, but I kept this as a separate patch in case someone ends running a git bisect. Signed-off-by: Pete Zaitcev Signed-off-by: Greg Kroah-Hartman --- drivers/usb/class/usblp.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) --- a/drivers/usb/class/usblp.c +++ b/drivers/usb/class/usblp.c @@ -345,16 +345,17 @@ static int usblp_check_status(struct usb unsigned char status, newerr = 0; int error; - error = usblp_read_status (usblp, usblp->statusbuf); - if (error < 0) { + mutex_lock(&usblp->mut); + if ((error = usblp_read_status(usblp, usblp->statusbuf)) < 0) { + mutex_unlock(&usblp->mut); if (printk_ratelimit()) printk(KERN_ERR "usblp%d: error %d reading printer status\n", usblp->minor, error); return 0; } - status = *usblp->statusbuf; + mutex_unlock(&usblp->mut); if (~status & LP_PERRORP) newerr = 3;