# This is a BitKeeper generated patch for the following project: # Project Name: Linux kernel tree # This patch format is intended for GNU patch command version 2.5 or higher. # This patch includes the following deltas: # ChangeSet 1.483 -> 1.484 # drivers/usb/class/printer.c 1.26 -> 1.27 # # The following is the BitKeeper ChangeSet Log # -------------------------------------------- # 02/06/13 flavien@lebarbe.net 1.484 # [PATCH] usblp_ioctl for non-little-endian machines # # ioctl(LPGETSTATUS) is known to put the status into an int. The usblp # driver has a problem in this area as it does not put it into an int but # into a char. Let's see : # # from drivers/char/lp.c : lp_ioctl : # int status # copy_to_user((int *) arg, &status, sizeof(int)) # # from drivers/usb/printer.c : usblp_ioctl : # unsigned char status; # copy_to_user ((unsigned char *)arg, &status, 1) # # Even though in most cases it can work unnoticed on little-endian # machines ;o), it's broken on non-little-endian machines (I got bitten on # PPC). # -------------------------------------------- # diff -Nru a/drivers/usb/class/printer.c b/drivers/usb/class/printer.c --- a/drivers/usb/class/printer.c Fri Jun 14 14:15:30 2002 +++ b/drivers/usb/class/printer.c Fri Jun 14 14:15:30 2002 @@ -418,7 +418,8 @@ { struct usblp *usblp = file->private_data; int length, err, i; - unsigned char status, newChannel; + unsigned char lpstatus, newChannel; + int status; int twoints[2]; int retval = 0; @@ -569,12 +570,13 @@ switch (cmd) { case LPGETSTATUS: - if (usblp_read_status(usblp, &status)) { + if (usblp_read_status(usblp, &lpstatus)) { err("usblp%d: failed reading printer status", usblp->minor); retval = -EIO; goto done; } - if (copy_to_user ((unsigned char *)arg, &status, 1)) + status = lpstatus; + if (copy_to_user ((int *)arg, &status, sizeof(int))) retval = -EFAULT; break;