[PATCH 1/2] drm/vmwgfx: use kzalloc in vmw_surface_define_ioctl()

kbuild test robot lkp at intel.com
Wed Sep 30 13:54:47 PDT 2015


Hi Rasmus,

[auto build test results on v4.3-rc3 -- if it's inappropriate base, please ignore]


coccinelle warnings: (new ones prefixed by >>)

>> drivers/gpu/drm/vmwgfx/vmwgfx_surface.c:771:1-13: alloc with no test, possible model on line 817

vim +771 drivers/gpu/drm/vmwgfx/vmwgfx_surface.c

543831cf Thomas Hellstrom 2012-11-20  765  
543831cf Thomas Hellstrom 2012-11-20  766  	srf->sizes = kmalloc(srf->num_sizes * sizeof(*srf->sizes), GFP_KERNEL);
543831cf Thomas Hellstrom 2012-11-20  767  	if (unlikely(srf->sizes == NULL)) {
543831cf Thomas Hellstrom 2012-11-20  768  		ret = -ENOMEM;
543831cf Thomas Hellstrom 2012-11-20  769  		goto out_no_sizes;
543831cf Thomas Hellstrom 2012-11-20  770  	}
543831cf Thomas Hellstrom 2012-11-20 @771  	srf->offsets = kmalloc(srf->num_sizes * sizeof(*srf->offsets),
543831cf Thomas Hellstrom 2012-11-20  772  			       GFP_KERNEL);
543831cf Thomas Hellstrom 2012-11-20  773  	if (unlikely(srf->sizes == NULL)) {
543831cf Thomas Hellstrom 2012-11-20  774  		ret = -ENOMEM;
543831cf Thomas Hellstrom 2012-11-20  775  		goto out_no_offsets;
543831cf Thomas Hellstrom 2012-11-20  776  	}
543831cf Thomas Hellstrom 2012-11-20  777  
543831cf Thomas Hellstrom 2012-11-20  778  	user_sizes = (struct drm_vmw_size __user *)(unsigned long)
543831cf Thomas Hellstrom 2012-11-20  779  	    req->size_addr;
543831cf Thomas Hellstrom 2012-11-20  780  
543831cf Thomas Hellstrom 2012-11-20  781  	ret = copy_from_user(srf->sizes, user_sizes,
543831cf Thomas Hellstrom 2012-11-20  782  			     srf->num_sizes * sizeof(*srf->sizes));
543831cf Thomas Hellstrom 2012-11-20  783  	if (unlikely(ret != 0)) {
543831cf Thomas Hellstrom 2012-11-20  784  		ret = -EFAULT;
543831cf Thomas Hellstrom 2012-11-20  785  		goto out_no_copy;
543831cf Thomas Hellstrom 2012-11-20  786  	}
543831cf Thomas Hellstrom 2012-11-20  787  
543831cf Thomas Hellstrom 2012-11-20  788  	srf->base_size = *srf->sizes;
543831cf Thomas Hellstrom 2012-11-20  789  	srf->autogen_filter = SVGA3D_TEX_FILTER_NONE;
15c6f656 Zack Rusin       2012-11-21  790  	srf->multisample_count = 0;
543831cf Thomas Hellstrom 2012-11-20  791  
543831cf Thomas Hellstrom 2012-11-20  792  	cur_bo_offset = 0;
543831cf Thomas Hellstrom 2012-11-20  793  	cur_offset = srf->offsets;
543831cf Thomas Hellstrom 2012-11-20  794  	cur_size = srf->sizes;
543831cf Thomas Hellstrom 2012-11-20  795  
543831cf Thomas Hellstrom 2012-11-20  796  	for (i = 0; i < DRM_VMW_MAX_SURFACE_FACES; ++i) {
543831cf Thomas Hellstrom 2012-11-20  797  		for (j = 0; j < srf->mip_levels[i]; ++j) {
7e8d9da3 Thomas Hellstrom 2012-11-20  798  			uint32_t stride = svga3dsurface_calculate_pitch
7e8d9da3 Thomas Hellstrom 2012-11-20  799  				(desc, cur_size);
543831cf Thomas Hellstrom 2012-11-20  800  
543831cf Thomas Hellstrom 2012-11-20  801  			cur_offset->face = i;
543831cf Thomas Hellstrom 2012-11-20  802  			cur_offset->mip = j;
543831cf Thomas Hellstrom 2012-11-20  803  			cur_offset->bo_offset = cur_bo_offset;
7e8d9da3 Thomas Hellstrom 2012-11-20  804  			cur_bo_offset += svga3dsurface_get_image_buffer_size
7e8d9da3 Thomas Hellstrom 2012-11-20  805  				(desc, cur_size, stride);
543831cf Thomas Hellstrom 2012-11-20  806  			++cur_offset;
543831cf Thomas Hellstrom 2012-11-20  807  			++cur_size;
543831cf Thomas Hellstrom 2012-11-20  808  		}
543831cf Thomas Hellstrom 2012-11-20  809  	}
543831cf Thomas Hellstrom 2012-11-20  810  	res->backup_size = cur_bo_offset;
543831cf Thomas Hellstrom 2012-11-20  811  	if (srf->scanout &&
543831cf Thomas Hellstrom 2012-11-20  812  	    srf->num_sizes == 1 &&
543831cf Thomas Hellstrom 2012-11-20  813  	    srf->sizes[0].width == 64 &&
543831cf Thomas Hellstrom 2012-11-20  814  	    srf->sizes[0].height == 64 &&
543831cf Thomas Hellstrom 2012-11-20  815  	    srf->format == SVGA3D_A8R8G8B8) {
543831cf Thomas Hellstrom 2012-11-20  816  
fc815f88 Rasmus Villemoes 2015-09-30 @817  		srf->snooper.image = kzalloc(64 * 64 * 4, GFP_KERNEL);
fc815f88 Rasmus Villemoes 2015-09-30  818  		if (!srf->snooper.image) {
543831cf Thomas Hellstrom 2012-11-20  819  			DRM_ERROR("Failed to allocate cursor_image\n");
543831cf Thomas Hellstrom 2012-11-20  820  			ret = -ENOMEM;

:::::: The code at line 771 was first introduced by commit
:::::: 543831cfc976669b8da963b3e94933e21e051846 drm/vmwgfx: Break out surface and context management to separate files

:::::: TO: Thomas Hellstrom <thellstrom at vmware.com>
:::::: CC: Dave Airlie <airlied at redhat.com>

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation


More information about the dri-devel mailing list