diff options
-rw-r--r-- | drivers/input/ff-core.c | 11 | ||||
-rw-r--r-- | include/linux/input.h | 2 | ||||
-rw-r--r-- | include/linux/uinput.h | 2 |
3 files changed, 10 insertions, 5 deletions
diff --git a/drivers/input/ff-core.c b/drivers/input/ff-core.c index 3367f760d75a..480eb9d9876a 100644 --- a/drivers/input/ff-core.c +++ b/drivers/input/ff-core.c | |||
@@ -309,9 +309,10 @@ EXPORT_SYMBOL_GPL(input_ff_event); | |||
309 | * Once ff device is created you need to setup its upload, erase, | 309 | * Once ff device is created you need to setup its upload, erase, |
310 | * playback and other handlers before registering input device | 310 | * playback and other handlers before registering input device |
311 | */ | 311 | */ |
312 | int input_ff_create(struct input_dev *dev, int max_effects) | 312 | int input_ff_create(struct input_dev *dev, unsigned int max_effects) |
313 | { | 313 | { |
314 | struct ff_device *ff; | 314 | struct ff_device *ff; |
315 | size_t ff_dev_size; | ||
315 | int i; | 316 | int i; |
316 | 317 | ||
317 | if (!max_effects) { | 318 | if (!max_effects) { |
@@ -319,8 +320,12 @@ int input_ff_create(struct input_dev *dev, int max_effects) | |||
319 | return -EINVAL; | 320 | return -EINVAL; |
320 | } | 321 | } |
321 | 322 | ||
322 | ff = kzalloc(sizeof(struct ff_device) + | 323 | ff_dev_size = sizeof(struct ff_device) + |
323 | max_effects * sizeof(struct file *), GFP_KERNEL); | 324 | max_effects * sizeof(struct file *); |
325 | if (ff_dev_size < max_effects) /* overflow */ | ||
326 | return -EINVAL; | ||
327 | |||
328 | ff = kzalloc(ff_dev_size, GFP_KERNEL); | ||
324 | if (!ff) | 329 | if (!ff) |
325 | return -ENOMEM; | 330 | return -ENOMEM; |
326 | 331 | ||
diff --git a/include/linux/input.h b/include/linux/input.h index 57add325e7a8..6d5eddb18c82 100644 --- a/include/linux/input.h +++ b/include/linux/input.h | |||
@@ -1610,7 +1610,7 @@ struct ff_device { | |||
1610 | struct file *effect_owners[]; | 1610 | struct file *effect_owners[]; |
1611 | }; | 1611 | }; |
1612 | 1612 | ||
1613 | int input_ff_create(struct input_dev *dev, int max_effects); | 1613 | int input_ff_create(struct input_dev *dev, unsigned int max_effects); |
1614 | void input_ff_destroy(struct input_dev *dev); | 1614 | void input_ff_destroy(struct input_dev *dev); |
1615 | 1615 | ||
1616 | int input_ff_event(struct input_dev *dev, unsigned int type, unsigned int code, int value); | 1616 | int input_ff_event(struct input_dev *dev, unsigned int type, unsigned int code, int value); |
diff --git a/include/linux/uinput.h b/include/linux/uinput.h index d28c726ede4f..2aa2881b0df9 100644 --- a/include/linux/uinput.h +++ b/include/linux/uinput.h | |||
@@ -68,7 +68,7 @@ struct uinput_device { | |||
68 | unsigned char head; | 68 | unsigned char head; |
69 | unsigned char tail; | 69 | unsigned char tail; |
70 | struct input_event buff[UINPUT_BUFFER_SIZE]; | 70 | struct input_event buff[UINPUT_BUFFER_SIZE]; |
71 | int ff_effects_max; | 71 | unsigned int ff_effects_max; |
72 | 72 | ||
73 | struct uinput_request *requests[UINPUT_NUM_REQUESTS]; | 73 | struct uinput_request *requests[UINPUT_NUM_REQUESTS]; |
74 | wait_queue_head_t requests_waitq; | 74 | wait_queue_head_t requests_waitq; |