summaryrefslogtreecommitdiffstats
path: root/drivers/input/ff-core.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/input/ff-core.c')
-rw-r--r--drivers/input/ff-core.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/drivers/input/ff-core.c b/drivers/input/ff-core.c
index 16231fe080..609a5f0176 100644
--- a/drivers/input/ff-core.c
+++ b/drivers/input/ff-core.c
@@ -9,8 +9,10 @@
/* #define DEBUG */
#include <linux/input.h>
+#include <linux/limits.h>
#include <linux/module.h>
#include <linux/mutex.h>
+#include <linux/overflow.h>
#include <linux/sched.h>
#include <linux/slab.h>
@@ -315,9 +317,8 @@ int input_ff_create(struct input_dev *dev, unsigned int max_effects)
return -EINVAL;
}
- ff_dev_size = sizeof(struct ff_device) +
- max_effects * sizeof(struct file *);
- if (ff_dev_size < max_effects) /* overflow */
+ ff_dev_size = struct_size(ff, effect_owners, max_effects);
+ if (ff_dev_size == SIZE_MAX) /* overflow */
return -EINVAL;
ff = kzalloc(ff_dev_size, GFP_KERNEL);