diff options
author | Pete Zaitcev <zaitcev@redhat.com> | 2007-08-14 01:50:13 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2007-10-12 17:55:14 -0400 |
commit | fc401e697f8c00ad1178a6758e86e3881dfa3181 (patch) | |
tree | b744e6b010f646b21c6185896141252c49d91de2 /drivers/usb/class/usblp.c | |
parent | 7b5cd5fefbe023625a7ff7604e8beb9a15a9efab (diff) |
usblp: mutex in usblp_check_status
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>
Diffstat (limited to 'drivers/usb/class/usblp.c')
-rw-r--r-- | drivers/usb/class/usblp.c | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/drivers/usb/class/usblp.c b/drivers/usb/class/usblp.c index 9696668e5752..2c4a359355ba 100644 --- a/drivers/usb/class/usblp.c +++ b/drivers/usb/class/usblp.c | |||
@@ -345,16 +345,17 @@ static int usblp_check_status(struct usblp *usblp, int err) | |||
345 | unsigned char status, newerr = 0; | 345 | unsigned char status, newerr = 0; |
346 | int error; | 346 | int error; |
347 | 347 | ||
348 | error = usblp_read_status (usblp, usblp->statusbuf); | 348 | mutex_lock(&usblp->mut); |
349 | if (error < 0) { | 349 | if ((error = usblp_read_status(usblp, usblp->statusbuf)) < 0) { |
350 | mutex_unlock(&usblp->mut); | ||
350 | if (printk_ratelimit()) | 351 | if (printk_ratelimit()) |
351 | printk(KERN_ERR | 352 | printk(KERN_ERR |
352 | "usblp%d: error %d reading printer status\n", | 353 | "usblp%d: error %d reading printer status\n", |
353 | usblp->minor, error); | 354 | usblp->minor, error); |
354 | return 0; | 355 | return 0; |
355 | } | 356 | } |
356 | |||
357 | status = *usblp->statusbuf; | 357 | status = *usblp->statusbuf; |
358 | mutex_unlock(&usblp->mut); | ||
358 | 359 | ||
359 | if (~status & LP_PERRORP) | 360 | if (~status & LP_PERRORP) |
360 | newerr = 3; | 361 | newerr = 3; |