diff options
author | Elias Vanderstuyft <elias.vds@gmail.com> | 2015-12-18 20:32:19 -0500 |
---|---|---|
committer | Dmitry Torokhov <dmitry.torokhov@gmail.com> | 2015-12-18 20:48:52 -0500 |
commit | daf6cd0c1829c48cba197bd87d57fc8bf3f65faa (patch) | |
tree | cfc0ce649b7a874b3964efc55b44c6c45d38b77c | |
parent | fbae10db094046dba1d59e1c2ee5140835045f14 (diff) |
Input: uinput - sanity check on ff_effects_max and EV_FF
Currently the user can set ff_effects_max to zero with the EV_FF bit (and
the FF_GAIN and/or FF_AUTOCENTER bits) set, in this case the uninitialized
methods ff->set_gain and/or ff->set_autocenter can be dereferenced,
resulting in a kernel oops.
Check in uinput_create_device() and print a helpful message and return
-EINVAL in case the check fails.
Signed-off-by: Elias Vanderstuyft <elias.vds@gmail.com>
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
-rw-r--r-- | drivers/input/misc/uinput.c | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/drivers/input/misc/uinput.c b/drivers/input/misc/uinput.c index 782df415e4d5..4eb9e4d94f46 100644 --- a/drivers/input/misc/uinput.c +++ b/drivers/input/misc/uinput.c | |||
@@ -272,6 +272,13 @@ static int uinput_create_device(struct uinput_device *udev) | |||
272 | input_set_events_per_packet(dev, 60); | 272 | input_set_events_per_packet(dev, 60); |
273 | } | 273 | } |
274 | 274 | ||
275 | if (test_bit(EV_FF, dev->evbit) && !udev->ff_effects_max) { | ||
276 | printk(KERN_DEBUG "%s: ff_effects_max should be non-zero when FF_BIT is set\n", | ||
277 | UINPUT_NAME); | ||
278 | error = -EINVAL; | ||
279 | goto fail1; | ||
280 | } | ||
281 | |||
275 | if (udev->ff_effects_max) { | 282 | if (udev->ff_effects_max) { |
276 | error = input_ff_create(dev, udev->ff_effects_max); | 283 | error = input_ff_create(dev, udev->ff_effects_max); |
277 | if (error) | 284 | if (error) |