]> pilppa.com Git - linux-2.6-omap-h63xx.git/commitdiff
usblp: mutex in usblp_check_status
authorPete Zaitcev <zaitcev@redhat.com>
Tue, 14 Aug 2007 05:50:13 +0000 (22:50 -0700)
committerGreg Kroah-Hartman <gregkh@suse.de>
Fri, 12 Oct 2007 21:55:14 +0000 (14:55 -0700)
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 <zaitcev@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
drivers/usb/class/usblp.c

index 9696668e5752a5ce3745ea560664e2e4d97912bd..2c4a359355ba81b36dba1d4f0d90fb82d03a0788 100644 (file)
@@ -345,16 +345,17 @@ static int usblp_check_status(struct usblp *usblp, int err)
        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;