linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [linux-next:master 13152/13159] drivers/gpu/drm/i915/gt/shmem_utils.c:76 shmem_pin_map() warn: always true condition '(--i >= 0) => (0-u64max >= 0)'
@ 2020-10-03 21:07 kernel test robot
  2020-10-06  7:55 ` Christoph Hellwig
  0 siblings, 1 reply; 2+ messages in thread
From: kernel test robot @ 2020-10-03 21:07 UTC (permalink / raw)
  To: Christoph Hellwig
  Cc: kbuild-all, Tvrtko Ursulin, Andrew Morton, Linux Memory Management List

[-- Attachment #1: Type: text/plain, Size: 1719 bytes --]

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git master
head:   2172e358cd1713c5b7c31361ac465edfe55e455c
commit: 400b65cb5acbcbe227c95f098349e02f77e04d88 [13152/13159] drm/i915: use vmap in shmem_pin_map
config: x86_64-randconfig-m001-20201004 (attached as .config)
compiler: gcc-9 (Debian 9.3.0-15) 9.3.0

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>

smatch warnings:
drivers/gpu/drm/i915/gt/shmem_utils.c:76 shmem_pin_map() warn: always true condition '(--i >= 0) => (0-u64max >= 0)'
drivers/gpu/drm/i915/gt/shmem_utils.c:76 shmem_pin_map() warn: always true condition '(--i >= 0) => (0-u64max >= 0)'

vim +76 drivers/gpu/drm/i915/gt/shmem_utils.c

    51	
    52	void *shmem_pin_map(struct file *file)
    53	{
    54		struct page **pages;
    55		size_t n_pages, i;
    56		void *vaddr;
    57	
    58		n_pages = file->f_mapping->host->i_size >> PAGE_SHIFT;
    59		pages = kvmalloc_array(n_pages, sizeof(*pages), GFP_KERNEL);
    60		if (!pages)
    61			return NULL;
    62	
    63		for (i = 0; i < n_pages; i++) {
    64			pages[i] = shmem_read_mapping_page_gfp(file->f_mapping, i,
    65							       GFP_KERNEL);
    66			if (IS_ERR(pages[i]))
    67				goto err_page;
    68		}
    69	
    70		vaddr = vmap(pages, n_pages, VM_MAP_PUT_PAGES, PAGE_KERNEL);
    71		if (!vaddr)
    72			goto err_page;
    73		mapping_set_unevictable(file->f_mapping);
    74		return vaddr;
    75	err_page:
  > 76		while (--i >= 0)
    77			put_page(pages[i]);
    78		kvfree(pages);
    79		return NULL;
    80	}
    81	

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org

[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 34215 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [linux-next:master 13152/13159] drivers/gpu/drm/i915/gt/shmem_utils.c:76 shmem_pin_map() warn: always true condition '(--i >= 0) => (0-u64max >= 0)'
  2020-10-03 21:07 [linux-next:master 13152/13159] drivers/gpu/drm/i915/gt/shmem_utils.c:76 shmem_pin_map() warn: always true condition '(--i >= 0) => (0-u64max >= 0)' kernel test robot
@ 2020-10-06  7:55 ` Christoph Hellwig
  0 siblings, 0 replies; 2+ messages in thread
From: Christoph Hellwig @ 2020-10-06  7:55 UTC (permalink / raw)
  To: kernel test robot
  Cc: Christoph Hellwig, kbuild-all, Tvrtko Ursulin, Andrew Morton,
	Linux Memory Management List

Thanks for the report.  The patch below takes care of it, and also
uses the right type for a page index.  Andrew, can you fold it in?

diff --git a/drivers/gpu/drm/i915/gt/shmem_utils.c b/drivers/gpu/drm/i915/gt/shmem_utils.c
index f011ea42487e11..4f043f2520f78d 100644
--- a/drivers/gpu/drm/i915/gt/shmem_utils.c
+++ b/drivers/gpu/drm/i915/gt/shmem_utils.c
@@ -52,7 +52,7 @@ struct file *shmem_create_from_object(struct drm_i915_gem_object *obj)
 void *shmem_pin_map(struct file *file)
 {
 	struct page **pages;
-	size_t n_pages, i;
+	pgoff_t n_pages, i, j;
 	void *vaddr;
 
 	n_pages = file->f_mapping->host->i_size >> PAGE_SHIFT;
@@ -73,8 +73,8 @@ void *shmem_pin_map(struct file *file)
 	mapping_set_unevictable(file->f_mapping);
 	return vaddr;
 err_page:
-	while (--i >= 0)
-		put_page(pages[i]);
+	for (j = 0; j < i; j++)
+		put_page(pages[j]);
 	kvfree(pages);
 	return NULL;
 }


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-10-06  7:55 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-03 21:07 [linux-next:master 13152/13159] drivers/gpu/drm/i915/gt/shmem_utils.c:76 shmem_pin_map() warn: always true condition '(--i >= 0) => (0-u64max >= 0)' kernel test robot
2020-10-06  7:55 ` Christoph Hellwig

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).