lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Message-ID: <202409080613.QLumunSL-lkp@intel.com>
Date: Sun, 8 Sep 2024 06:30:14 +0800
From: kernel test robot <lkp@...el.com>
To: Zack Rusin <zack.rusin@...adcom.com>
Cc: oe-kbuild-all@...ts.linux.dev, linux-kernel@...r.kernel.org,
	Martin Krastev <martin.krastev@...adcom.com>
Subject: drivers/gpu/drm/vmwgfx/vmwgfx_blit.c:533:2-8: WARNING: NULL check
 before some freeing functions is not needed.

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head:   b31c4492884252a8360f312a0ac2049349ddf603
commit: b32233accefff1338806f064fb9b62cf5bc0609f drm/vmwgfx: Fix prime import/export
date:   5 months ago
config: i386-randconfig-054-20240907 (https://download.01.org/0day-ci/archive/20240908/202409080613.QLumunSL-lkp@intel.com/config)
compiler: gcc-12 (Debian 12.2.0-14) 12.2.0

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@...el.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202409080613.QLumunSL-lkp@intel.com/

cocci warnings: (new ones prefixed by >>)
>> drivers/gpu/drm/vmwgfx/vmwgfx_blit.c:533:2-8: WARNING: NULL check before some freeing functions is not needed.
   drivers/gpu/drm/vmwgfx/vmwgfx_blit.c:535:2-8: WARNING: NULL check before some freeing functions is not needed.

vim +533 drivers/gpu/drm/vmwgfx/vmwgfx_blit.c

   422	
   423	/**
   424	 * vmw_bo_cpu_blit - in-kernel cpu blit.
   425	 *
   426	 * @dst: Destination buffer object.
   427	 * @dst_offset: Destination offset of blit start in bytes.
   428	 * @dst_stride: Destination stride in bytes.
   429	 * @src: Source buffer object.
   430	 * @src_offset: Source offset of blit start in bytes.
   431	 * @src_stride: Source stride in bytes.
   432	 * @w: Width of blit.
   433	 * @h: Height of blit.
   434	 * @diff: The struct vmw_diff_cpy used to track the modified bounding box.
   435	 * return: Zero on success. Negative error value on failure. Will print out
   436	 * kernel warnings on caller bugs.
   437	 *
   438	 * Performs a CPU blit from one buffer object to another avoiding a full
   439	 * bo vmap which may exhaust- or fragment vmalloc space.
   440	 * On supported architectures (x86), we're using kmap_atomic which avoids
   441	 * cross-processor TLB- and cache flushes and may, on non-HIGHMEM systems
   442	 * reference already set-up mappings.
   443	 *
   444	 * Neither of the buffer objects may be placed in PCI memory
   445	 * (Fixed memory in TTM terminology) when using this function.
   446	 */
   447	int vmw_bo_cpu_blit(struct ttm_buffer_object *dst,
   448			    u32 dst_offset, u32 dst_stride,
   449			    struct ttm_buffer_object *src,
   450			    u32 src_offset, u32 src_stride,
   451			    u32 w, u32 h,
   452			    struct vmw_diff_cpy *diff)
   453	{
   454		struct ttm_operation_ctx ctx = {
   455			.interruptible = false,
   456			.no_wait_gpu = false
   457		};
   458		u32 j, initial_line = dst_offset / dst_stride;
   459		struct vmw_bo_blit_line_data d = {0};
   460		int ret = 0;
   461		struct page **dst_pages = NULL;
   462		struct page **src_pages = NULL;
   463	
   464		/* Buffer objects need to be either pinned or reserved: */
   465		if (!(dst->pin_count))
   466			dma_resv_assert_held(dst->base.resv);
   467		if (!(src->pin_count))
   468			dma_resv_assert_held(src->base.resv);
   469	
   470		if (!ttm_tt_is_populated(dst->ttm)) {
   471			ret = dst->bdev->funcs->ttm_tt_populate(dst->bdev, dst->ttm, &ctx);
   472			if (ret)
   473				return ret;
   474		}
   475	
   476		if (!ttm_tt_is_populated(src->ttm)) {
   477			ret = src->bdev->funcs->ttm_tt_populate(src->bdev, src->ttm, &ctx);
   478			if (ret)
   479				return ret;
   480		}
   481	
   482		if (!src->ttm->pages && src->ttm->sg) {
   483			src_pages = kvmalloc_array(src->ttm->num_pages,
   484						   sizeof(struct page *), GFP_KERNEL);
   485			if (!src_pages)
   486				return -ENOMEM;
   487			ret = drm_prime_sg_to_page_array(src->ttm->sg, src_pages,
   488							 src->ttm->num_pages);
   489			if (ret)
   490				goto out;
   491		}
   492		if (!dst->ttm->pages && dst->ttm->sg) {
   493			dst_pages = kvmalloc_array(dst->ttm->num_pages,
   494						   sizeof(struct page *), GFP_KERNEL);
   495			if (!dst_pages) {
   496				ret = -ENOMEM;
   497				goto out;
   498			}
   499			ret = drm_prime_sg_to_page_array(dst->ttm->sg, dst_pages,
   500							 dst->ttm->num_pages);
   501			if (ret)
   502				goto out;
   503		}
   504	
   505		d.mapped_dst = 0;
   506		d.mapped_src = 0;
   507		d.dst_addr = NULL;
   508		d.src_addr = NULL;
   509		d.dst_pages = dst->ttm->pages ? dst->ttm->pages : dst_pages;
   510		d.src_pages = src->ttm->pages ? src->ttm->pages : src_pages;
   511		d.dst_num_pages = PFN_UP(dst->resource->size);
   512		d.src_num_pages = PFN_UP(src->resource->size);
   513		d.dst_prot = ttm_io_prot(dst, dst->resource, PAGE_KERNEL);
   514		d.src_prot = ttm_io_prot(src, src->resource, PAGE_KERNEL);
   515		d.diff = diff;
   516	
   517		for (j = 0; j < h; ++j) {
   518			diff->line = j + initial_line;
   519			diff->line_offset = dst_offset % dst_stride;
   520			ret = vmw_bo_cpu_blit_line(&d, dst_offset, src_offset, w);
   521			if (ret)
   522				goto out;
   523	
   524			dst_offset += dst_stride;
   525			src_offset += src_stride;
   526		}
   527	out:
   528		if (d.src_addr)
   529			kunmap_atomic(d.src_addr);
   530		if (d.dst_addr)
   531			kunmap_atomic(d.dst_addr);
   532		if (src_pages)
 > 533			kvfree(src_pages);

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ