patch-2.3.99-pre4 linux/drivers/usb/printer.c

Next file: linux/drivers/usb/scanner.c
Previous file: linux/drivers/usb/pegasus.c
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.3.99-pre3/linux/drivers/usb/printer.c linux/drivers/usb/printer.c
@@ -160,10 +160,13 @@
 	if (usblp->used)
 		return -EBUSY;
 
-	if ((retval = usblp_check_status(usblp)))
+	MOD_INC_USE_COUNT;
+
+	if ((retval = usblp_check_status(usblp))) {
+		MOD_DEC_USE_COUNT;
 		return retval;
+	}
 
-	MOD_INC_USE_COUNT;
 	usblp->used = 1;
 	file->private_data = usblp;
 
@@ -179,17 +182,18 @@
 {
 	struct usblp *usblp = file->private_data;
 
-	MOD_DEC_USE_COUNT;
 	usblp->used = 0;
 			
 	if (usblp->dev) {
         	usb_unlink_urb(&usblp->readurb);
         	usb_unlink_urb(&usblp->writeurb);
+		MOD_DEC_USE_COUNT;
 		return 0;
 	}
 
 	usblp_table[usblp->minor] = NULL;
 	kfree(usblp);
+	MOD_DEC_USE_COUNT;
 
 	return 0;
 }

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)