qxl: use kmalloc_array to alloc reloc_info in qxl_process_single_command
Subsystems (4)
Gerd Hoffmann
maintainerPATCH v2 1/1 qxl: use kmalloc_array to alloc reloc_info in qxl_process_single_command
This avoids integer overflows on 32bit machines when calculating reloc_info size, as reported by Alan Cox.
--- drivers/gpu/drm/qxl/qxl_ioctl.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/qxl/qxl_ioctl.c +2 -1
@@ -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 ;
Signature · 1 line
1.8.3.1
Quoted 6 lines · Gerd Hoffmann
This avoids integer overflows on 32bit machines when calculating
reloc_infosize, as reported by Alan Cox.
Reviewed-by Daniel Vetter <[email protected]>
Quoted 21 lines
--- drivers/gpu/drm/qxl/qxl_ioctl.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)drivers/gpu/drm/qxl/qxl_ioctl.c +2
-1@@ -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 ;Signature · 1 line
1.8.3.1
Signature · 3 lines
Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch