Skip to content

Commit

Permalink
usblp: mutex in usblp_check_status
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Pete Zaitcev authored and Greg Kroah-Hartman committed Oct 12, 2007
1 parent 7b5cd5f commit fc401e6
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions drivers/usb/class/usblp.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit fc401e6

Please sign in to comment.