Skip to content

Commit

Permalink
Input: psmouse - fix attribute access on 64-bit systems
Browse files Browse the repository at this point in the history
psmouse_show_int_attr() and psmouse_set_int_attr() were accessing
unsigned int fields as unsigned long, which gave garbage on x86_64.

Signed-off-by: Sergey Vlasov <vsu@altlinux.ru>
Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
  • Loading branch information
Sergey Vlasov authored and Dmitry Torokhov committed Nov 9, 2006
1 parent 7215561 commit eb5d582
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions drivers/input/mouse/psmouse-base.c
Original file line number Diff line number Diff line change
Expand Up @@ -1349,21 +1349,24 @@ ssize_t psmouse_attr_set_helper(struct device *dev, struct device_attribute *dev

static ssize_t psmouse_show_int_attr(struct psmouse *psmouse, void *offset, char *buf)
{
unsigned long *field = (unsigned long *)((char *)psmouse + (size_t)offset);
unsigned int *field = (unsigned int *)((char *)psmouse + (size_t)offset);

return sprintf(buf, "%lu\n", *field);
return sprintf(buf, "%u\n", *field);
}

static ssize_t psmouse_set_int_attr(struct psmouse *psmouse, void *offset, const char *buf, size_t count)
{
unsigned long *field = (unsigned long *)((char *)psmouse + (size_t)offset);
unsigned int *field = (unsigned int *)((char *)psmouse + (size_t)offset);
unsigned long value;
char *rest;

value = simple_strtoul(buf, &rest, 10);
if (*rest)
return -EINVAL;

if ((unsigned int)value != value)
return -EINVAL;

*field = value;

return count;
Expand Down

0 comments on commit eb5d582

Please sign in to comment.