drm/qxl: use kmalloc_array to alloc reloc_info in qxl_process_single_command
authorGerd Hoffmann <[email protected]>
Tue, 16 Feb 2016 13:25:00 +0000 (14:25 +0100)
committerDave Airlie <[email protected]>
Wed, 17 Feb 2016 04:16:06 +0000 (14:16 +1000)
This avoids integer overflows on 32bit machines when calculating
reloc_info size, as reported by Alan Cox.

Cc: [email protected]
Cc: [email protected]
Signed-off-by: Gerd Hoffmann <[email protected]>
Reviewed-by: Daniel Vetter <[email protected]>
Signed-off-by: Dave Airlie <[email protected]>
drivers/gpu/drm/qxl/qxl_ioctl.c

index 2ae8577497ca6e1c9cc87b265ff7ca92ee5375ec..7c2e78201ead9d475c3ba97d083c523026c21a47 100644 (file)
@@ -168,7 +168,8 @@ static int qxl_process_single_command(struct qxl_device *qdev,
                       cmd->command_size))
                return -EFAULT;
 
-       reloc_info = kmalloc(sizeof(struct qxl_reloc_info) * cmd->relocs_num, GFP_KERNEL);
+       reloc_info = kmalloc_array(cmd->relocs_num,
+                                  sizeof(struct qxl_reloc_info), GFP_KERNEL);
        if (!reloc_info)
                return -ENOMEM;