]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
[PATCH] Input: psmouse - fix attribute access on 64-bit systems
authorSergey Vlasov <vsu@altlinux.ru>
Tue, 7 Nov 2006 17:02:36 +0000 (20:02 +0300)
committerChris Wright <chrisw@sous-sol.org>
Sun, 19 Nov 2006 03:28:02 +0000 (19:28 -0800)
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: Chris Wright <chrisw@sous-sol.org>
drivers/input/mouse/psmouse-base.c

index 343afa38f4c2d2b1c38ae809097ea343d44a670a..07b060438c97c6aaa9c4e587056a22ed2ea92f48 100644 (file)
@@ -1332,20 +1332,22 @@ 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;