Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jikos/hid
[sfrench/cifs-2.6.git] / drivers / hid / hid-core.c
index a460ec147aeebcd729c1f4951c3340ac01fb81aa..3942ee61bd1c17e57867a7d8e5f521b5f8eae9b8 100644 (file)
@@ -134,8 +134,11 @@ static int open_collection(struct hid_parser *parser, unsigned type)
        }
 
        if (parser->device->maxcollection == parser->device->collection_size) {
-               collection = kmalloc(sizeof(struct hid_collection) *
-                               parser->device->collection_size * 2, GFP_KERNEL);
+               collection = kmalloc(
+                               array3_size(sizeof(struct hid_collection),
+                                           parser->device->collection_size,
+                                           2),
+                               GFP_KERNEL);
                if (collection == NULL) {
                        hid_err(parser->device, "failed to reallocate collection array\n");
                        return -ENOMEM;
@@ -1278,7 +1281,7 @@ static void hid_input_field(struct hid_device *hid, struct hid_field *field,
        __s32 max = field->logical_maximum;
        __s32 *value;
 
-       value = kmalloc(sizeof(__s32) * count, GFP_ATOMIC);
+       value = kmalloc_array(count, sizeof(__s32), GFP_ATOMIC);
        if (!value)
                return;