Skip to content

Commit

Permalink
drm/qxl: use kmalloc_array to alloc reloc_info in qxl_process_single_…
Browse files Browse the repository at this point in the history
…command

This avoids integer overflows on 32bit machines when calculating
reloc_info size, as reported by Alan Cox.

Cc: stable@vger.kernel.org
Cc: gnomes@lxorguk.ukuu.org.uk
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Signed-off-by: Dave Airlie <airlied@redhat.com>
  • Loading branch information
Gerd Hoffmann authored and Dave Airlie committed Feb 17, 2016
1 parent e8f051e commit 3485570
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion drivers/gpu/drm/qxl/qxl_ioctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down

0 comments on commit 3485570

Please sign in to comment.