Skip to contentSkip to conversation

Input: psmouse - fix attribute access on 64-bit systems

PATCH New Sergey Vlasov 1 participant 1 message Nov 7, 2006 Input drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Input: psmouse - fix attribute access on 64-bit systems

psmouse_show_int_attr() and psmouse_set_int_attr() were accessing unsigned int fields as unsigned long, which gave garbage on x86_64.

---
 drivers/input/mouse/psmouse-base.c |    8 +++++---
 1 files changed, 5 insertions(+), 3 deletions(-)

The problem was found in 2.6.18.2; the same patch applies to the current tree.

drivers/input/mouse/psmouse-base.c +5 -3
index 343afa3..07b0604 100644
@@ -1332,20 +1332,22 @@ ssize_t psmouse_attr_set_helper(struct d
 
 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;
 
Signature · 1 line
1.4.3.3.gddcc6