Skip to contentSkip to conversation

Input: ff-core - silence an underflow warning

PATCH In review Dan Carpenter 2 participants 5 messages Sep 22, 2015 – Oct 2, 2015

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Input: ff-core - silence an underflow warning

My static checker complains that "value" comes from the user in evdev_do_ioctl() and we check that it's not too large here but we don't check that it's negative. It's harmless because the ->set_gain() and ->set_autocenter() functions truncate it to a valid u16 value, but we may as well fix it just to make the static checker happy.

drivers/input/ff-core.c +2 -2
index c642082..6a94c5f 100644
@@ -273,14 +273,14 @@ int input_ff_event(struct input_dev *dev, unsigned int type,
 
 	switch (code) {
 	case FF_GAIN:
-		if (!test_bit(FF_GAIN, dev->ffbit) || value > 0xffff)
+		if (!test_bit(FF_GAIN, dev->ffbit) || value > 0xffffUL)
 			break;
 
 		ff->set_gain(dev, value);
 		break;
 
 	case FF_AUTOCENTER:
-		if (!test_bit(FF_AUTOCENTER, dev->ffbit) || value > 0xffff)
+		if (!test_bit(FF_AUTOCENTER, dev->ffbit) || value > 0xffffUL)
 			break;
 
 		ff->set_autocenter(dev, value);
maintainer
#1 lore raw
Quoted 16 lines · Dan Carpenter

My static checker complains that "value" comes from the user in evdev_do_ioctl() and we check that it's not too large here but we don't check that it's negative. It's harmless because the ->set_gain() and ->set_autocenter() functions truncate it to a valid u16 value, but we may as well fix it just to make the static checker happy.

drivers/input/ff-core.c +0 -0
index c642082..6a94c5f 100644
@@ -273,14 +273,14 @@ int input_ff_event(struct input_dev *dev, unsigned int type,
 
 	switch (code) {
 	case FF_GAIN:

drivers/input/ff-core.c int input_ff_event(struct input_dev *dev, unsigned int type, · line 283

Quoted 10 lines
drivers/input/ff-core.c +2 -2
-		if (!test_bit(FF_GAIN, dev->ffbit) || value > 0xffff)
+		if (!test_bit(FF_GAIN, dev->ffbit) || value > 0xffffUL)
 			break;
 
 		ff->set_gain(dev, value);
 		break;
 
 	case FF_AUTOCENTER:
-		if (!test_bit(FF_AUTOCENTER, dev->ffbit) || value > 0xffff)
+		if (!test_bit(FF_AUTOCENTER, dev->ffbit) || value > 0xffffUL)

Why UL and not U?

Thanks.

Quoted 3 lines
drivers/input/ff-core.c +0 -0
 			break;
 
 		ff->set_autocenter(dev, value);
Signature · 1 line
Dmitry
#2 lore raw
Quoted 21 lines · Dmitry Torokhov
Quoted 20 lines · Dan Carpenter

My static checker complains that "value" comes from the user in evdev_do_ioctl() and we check that it's not too large here but we don't check that it's negative. It's harmless because the ->set_gain() and ->set_autocenter() functions truncate it to a valid u16 value, but we may as well fix it just to make the static checker happy.

drivers/input/ff-core.c +1 -1
index c642082..6a94c5f 100644
@@ -273,14 +273,14 @@ int input_ff_event(struct input_dev *dev, unsigned int type,
 
 	switch (code) {
 	case FF_GAIN:
-		if (!test_bit(FF_GAIN, dev->ffbit) || value > 0xffff)
+		if (!test_bit(FF_GAIN, dev->ffbit) || value > 0xffffUL)
 			break;
 
Quoted 9 lines

drivers/input/ff-core.c int input_ff_event(struct input_dev *dev, unsigned int type, · line 283

Quoted 6 lines
drivers/input/ff-core.c +1 -1
 		ff->set_gain(dev, value);
 		break;
 
 	case FF_AUTOCENTER:
-		if (!test_bit(FF_AUTOCENTER, dev->ffbit) || value > 0xffff)
+		if (!test_bit(FF_AUTOCENTER, dev->ffbit) || value > 0xffffUL)

Why UL and not U?

You're right. That could just be U. I'll resend.

regards,
dan carpenter

maintainer
#3 lore raw
Quoted 25 lines · Dan Carpenter
Quoted 24 lines · Dmitry Torokhov
Quoted 23 lines · Dan Carpenter

My static checker complains that "value" comes from the user in evdev_do_ioctl() and we check that it's not too large here but we don't check that it's negative. It's harmless because the ->set_gain() and ->set_autocenter() functions truncate it to a valid u16 value, but we may as well fix it just to make the static checker happy.

drivers/input/ff-core.c +1 -1
index c642082..6a94c5f 100644
@@ -273,14 +273,14 @@ int input_ff_event(struct input_dev *dev, unsigned int type,
 
 	switch (code) {
 	case FF_GAIN:
-		if (!test_bit(FF_GAIN, dev->ffbit) || value > 0xffff)
+		if (!test_bit(FF_GAIN, dev->ffbit) || value > 0xffffUL)
 			break;
 
 		ff->set_gain(dev, value);
 		break;
 
Quoted 8 lines
Quoted 6 lines

drivers/input/ff-core.c int input_ff_event(struct input_dev *dev, unsigned int type, · line 283

Quoted 3 lines
drivers/input/ff-core.c +1 -1
 	case FF_AUTOCENTER:
-		if (!test_bit(FF_AUTOCENTER, dev->ffbit) || value > 0xffff)
+		if (!test_bit(FF_AUTOCENTER, dev->ffbit) || value > 0xffffUL)

Why UL and not U?

You're right. That could just be U. I'll resend.

That's fine, I'll adjust on my side.

Thanks.

Signature · 1 line
Dmitry
#4 lore raw
Quoted 1 line · Dmitry Torokhov

That's fine, I'll adjust on my side.

Thanks!

regards,
dan carpenter