diff options
author | Dmitry Torokhov <dmitry.torokhov@gmail.com> | 2011-10-27 08:46:20 +0400 |
---|---|---|
committer | Dmitry Torokhov <dmitry.torokhov@gmail.com> | 2011-10-27 08:46:20 +0400 |
commit | 6ad390a25a9d1d8606b9b826878f0a30639dc2b3 (patch) | |
tree | 05aff14f02776bc0d59a1f777cb92df6f4456ba9 /drivers/input/ff-core.c | |
parent | d6069dae4700cf5290a75002c46b9be8ea7eef3c (diff) | |
parent | 3f48e7354358519e5b93f7f755ec270b3f8eafa0 (diff) | |
download | linux-6ad390a25a9d1d8606b9b826878f0a30639dc2b3.tar.xz |
Merge branch 'next' into for-linus
Diffstat (limited to 'drivers/input/ff-core.c')
-rw-r--r-- | drivers/input/ff-core.c | 11 |
1 files changed, 8 insertions, 3 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); * Once ff device is created you need to setup its upload, erase, * playback and other handlers before registering input device */ -int input_ff_create(struct input_dev *dev, int max_effects) +int input_ff_create(struct input_dev *dev, unsigned int max_effects) { struct ff_device *ff; + size_t ff_dev_size; int i; if (!max_effects) { @@ -319,8 +320,12 @@ int input_ff_create(struct input_dev *dev, int max_effects) return -EINVAL; } - ff = kzalloc(sizeof(struct ff_device) + - max_effects * sizeof(struct file *), GFP_KERNEL); + ff_dev_size = sizeof(struct ff_device) + + max_effects * sizeof(struct file *); + if (ff_dev_size < max_effects) /* overflow */ + return -EINVAL; + + ff = kzalloc(ff_dev_size, GFP_KERNEL); if (!ff) return -ENOMEM; |