Commit 4e562171 authored by Flavien Lebarbé's avatar Flavien Lebarbé Committed by Greg Kroah-Hartman

[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).
parent d94f43cd
...@@ -418,7 +418,8 @@ static int usblp_ioctl(struct inode *inode, struct file *file, unsigned int cmd, ...@@ -418,7 +418,8 @@ static int usblp_ioctl(struct inode *inode, struct file *file, unsigned int cmd,
{ {
struct usblp *usblp = file->private_data; struct usblp *usblp = file->private_data;
int length, err, i; int length, err, i;
unsigned char status, newChannel; unsigned char lpstatus, newChannel;
int status;
int twoints[2]; int twoints[2];
int retval = 0; int retval = 0;
...@@ -569,12 +570,13 @@ static int usblp_ioctl(struct inode *inode, struct file *file, unsigned int cmd, ...@@ -569,12 +570,13 @@ static int usblp_ioctl(struct inode *inode, struct file *file, unsigned int cmd,
switch (cmd) { switch (cmd) {
case LPGETSTATUS: case LPGETSTATUS:
if (usblp_read_status(usblp, &status)) { if (usblp_read_status(usblp, &lpstatus)) {
err("usblp%d: failed reading printer status", usblp->minor); err("usblp%d: failed reading printer status", usblp->minor);
retval = -EIO; retval = -EIO;
goto done; goto done;
} }
if (copy_to_user ((unsigned char *)arg, &status, 1)) status = lpstatus;
if (copy_to_user ((int *)arg, &status, sizeof(int)))
retval = -EFAULT; retval = -EFAULT;
break; break;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment