[PATCH v3 1/5] fbdev: Put mmap for deferred I/O into drivers

Dan Carpenter dan.carpenter at oracle.com
Thu Apr 28 09:43:38 UTC 2022


Hi Thomas,

url:    https://github.com/intel-lab-lkp/linux/commits/Thomas-Zimmermann/fbdev-Decouple-deferred-I-O-from-struct-page/20220426-200655
base:   0e7deff6446a4ba2c75f499a0bfa80cd6a15c129
config: i386-randconfig-m021 (https://download.01.org/0day-ci/archive/20220428/202204280832.sGHcYdgQ-lkp@intel.com/config)
compiler: gcc-11 (Debian 11.2.0-20) 11.2.0

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp at intel.com>
Reported-by: Dan Carpenter <dan.carpenter at oracle.com>

New smatch warnings:
drivers/video/fbdev/core/fbmem.c:1389 fb_mmap() warn: inconsistent returns '&info->mm_lock'.

Old smatch warnings:
drivers/video/fbdev/core/fbmem.c:1660 do_register_framebuffer() error: buffer overflow 'registered_fb' 32 <= 32 (assuming for loop doesn't break)

vim +1389 drivers/video/fbdev/core/fbmem.c

^1da177e4c3f41 drivers/video/fbmem.c            Linus Torvalds    2005-04-16  1333  static int
^1da177e4c3f41 drivers/video/fbmem.c            Linus Torvalds    2005-04-16  1334  fb_mmap(struct file *file, struct vm_area_struct * vma)
^1da177e4c3f41 drivers/video/fbmem.c            Linus Torvalds    2005-04-16  1335  {
c47747fde931c0 drivers/video/fbmem.c            Linus Torvalds    2011-05-11  1336  	struct fb_info *info = file_fb_info(file);
fc9bbca8f650e5 drivers/video/fbmem.c            Linus Torvalds    2013-04-19  1337  	unsigned long mmio_pgoff;
^1da177e4c3f41 drivers/video/fbmem.c            Linus Torvalds    2005-04-16  1338  	unsigned long start;
^1da177e4c3f41 drivers/video/fbmem.c            Linus Torvalds    2005-04-16  1339  	u32 len;
^1da177e4c3f41 drivers/video/fbmem.c            Linus Torvalds    2005-04-16  1340  
c47747fde931c0 drivers/video/fbmem.c            Linus Torvalds    2011-05-11  1341  	if (!info)
c47747fde931c0 drivers/video/fbmem.c            Linus Torvalds    2011-05-11  1342  		return -ENODEV;
537a1bf059fa31 drivers/video/fbmem.c            Krzysztof Helt    2009-06-30  1343  	mutex_lock(&info->mm_lock);
12281c8dda5a3b drivers/video/fbdev/core/fbmem.c Jani Nikula       2019-11-29  1344  
8a9ea404b61faa drivers/video/fbdev/core/fbmem.c Thomas Zimmermann 2022-04-26  1345  	if (info->fbops->fb_mmap) {
^1da177e4c3f41 drivers/video/fbmem.c            Linus Torvalds    2005-04-16  1346  		int res;
95cf9264d5f36c drivers/video/fbdev/core/fbmem.c Tom Lendacky      2017-07-17  1347  
95cf9264d5f36c drivers/video/fbdev/core/fbmem.c Tom Lendacky      2017-07-17  1348  		/*
95cf9264d5f36c drivers/video/fbdev/core/fbmem.c Tom Lendacky      2017-07-17  1349  		 * The framebuffer needs to be accessed decrypted, be sure
95cf9264d5f36c drivers/video/fbdev/core/fbmem.c Tom Lendacky      2017-07-17  1350  		 * SME protection is removed ahead of the call
95cf9264d5f36c drivers/video/fbdev/core/fbmem.c Tom Lendacky      2017-07-17  1351  		 */
95cf9264d5f36c drivers/video/fbdev/core/fbmem.c Tom Lendacky      2017-07-17  1352  		vma->vm_page_prot = pgprot_decrypted(vma->vm_page_prot);
8a9ea404b61faa drivers/video/fbdev/core/fbmem.c Thomas Zimmermann 2022-04-26  1353  		res = info->fbops->fb_mmap(info, vma);
537a1bf059fa31 drivers/video/fbmem.c            Krzysztof Helt    2009-06-30  1354  		mutex_unlock(&info->mm_lock);
^1da177e4c3f41 drivers/video/fbmem.c            Linus Torvalds    2005-04-16  1355  		return res;
8a9ea404b61faa drivers/video/fbdev/core/fbmem.c Thomas Zimmermann 2022-04-26  1356  #if IS_ENABLED(CONFIG_FB_DEFERRED_IO)
8a9ea404b61faa drivers/video/fbdev/core/fbmem.c Thomas Zimmermann 2022-04-26  1357  	} else if (info->fbdefio) {
8a9ea404b61faa drivers/video/fbdev/core/fbmem.c Thomas Zimmermann 2022-04-26  1358  		/*
8a9ea404b61faa drivers/video/fbdev/core/fbmem.c Thomas Zimmermann 2022-04-26  1359  		 * FB deferred I/O wants you to handle mmap in your drivers. At a
8a9ea404b61faa drivers/video/fbdev/core/fbmem.c Thomas Zimmermann 2022-04-26  1360  		 * minimum, point struct fb_ops.fb_mmap to fb_deferred_io_mmap().
8a9ea404b61faa drivers/video/fbdev/core/fbmem.c Thomas Zimmermann 2022-04-26  1361  		 */
8a9ea404b61faa drivers/video/fbdev/core/fbmem.c Thomas Zimmermann 2022-04-26  1362  		dev_warn_once(info->dev, "fbdev mmap not set up for deferred I/O.\n");
8a9ea404b61faa drivers/video/fbdev/core/fbmem.c Thomas Zimmermann 2022-04-26  1363  		return -ENODEV;

mutex_unlock(&info->mm_lock); before the return.

8a9ea404b61faa drivers/video/fbdev/core/fbmem.c Thomas Zimmermann 2022-04-26  1364  #endif
^1da177e4c3f41 drivers/video/fbmem.c            Linus Torvalds    2005-04-16  1365  	}
^1da177e4c3f41 drivers/video/fbmem.c            Linus Torvalds    2005-04-16  1366  
fc9bbca8f650e5 drivers/video/fbmem.c            Linus Torvalds    2013-04-19  1367  	/*
fc9bbca8f650e5 drivers/video/fbmem.c            Linus Torvalds    2013-04-19  1368  	 * Ugh. This can be either the frame buffer mapping, or
fc9bbca8f650e5 drivers/video/fbmem.c            Linus Torvalds    2013-04-19  1369  	 * if pgoff points past it, the mmio mapping.
fc9bbca8f650e5 drivers/video/fbmem.c            Linus Torvalds    2013-04-19  1370  	 */
^1da177e4c3f41 drivers/video/fbmem.c            Linus Torvalds    2005-04-16  1371  	start = info->fix.smem_start;
fc9bbca8f650e5 drivers/video/fbmem.c            Linus Torvalds    2013-04-19  1372  	len = info->fix.smem_len;
fc9bbca8f650e5 drivers/video/fbmem.c            Linus Torvalds    2013-04-19  1373  	mmio_pgoff = PAGE_ALIGN((start & ~PAGE_MASK) + len) >> PAGE_SHIFT;
fc9bbca8f650e5 drivers/video/fbmem.c            Linus Torvalds    2013-04-19  1374  	if (vma->vm_pgoff >= mmio_pgoff) {
138f296e140f79 drivers/video/fbmem.c            Tomi Valkeinen    2013-04-24  1375  		if (info->var.accel_flags) {
138f296e140f79 drivers/video/fbmem.c            Tomi Valkeinen    2013-04-24  1376  			mutex_unlock(&info->mm_lock);
138f296e140f79 drivers/video/fbmem.c            Tomi Valkeinen    2013-04-24  1377  			return -EINVAL;
138f296e140f79 drivers/video/fbmem.c            Tomi Valkeinen    2013-04-24  1378  		}
138f296e140f79 drivers/video/fbmem.c            Tomi Valkeinen    2013-04-24  1379  
fc9bbca8f650e5 drivers/video/fbmem.c            Linus Torvalds    2013-04-19  1380  		vma->vm_pgoff -= mmio_pgoff;
^1da177e4c3f41 drivers/video/fbmem.c            Linus Torvalds    2005-04-16  1381  		start = info->fix.mmio_start;
fc9bbca8f650e5 drivers/video/fbmem.c            Linus Torvalds    2013-04-19  1382  		len = info->fix.mmio_len;
^1da177e4c3f41 drivers/video/fbmem.c            Linus Torvalds    2005-04-16  1383  	}
537a1bf059fa31 drivers/video/fbmem.c            Krzysztof Helt    2009-06-30  1384  	mutex_unlock(&info->mm_lock);
fc9bbca8f650e5 drivers/video/fbmem.c            Linus Torvalds    2013-04-19  1385  
c07fbfd17e614a drivers/video/fbmem.c            Daniel De Graaf   2010-08-10  1386  	vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
fc9bbca8f650e5 drivers/video/fbmem.c            Linus Torvalds    2013-04-19  1387  	fb_pgprotect(file, vma, start);
fc9bbca8f650e5 drivers/video/fbmem.c            Linus Torvalds    2013-04-19  1388  
fc9bbca8f650e5 drivers/video/fbmem.c            Linus Torvalds    2013-04-19 @1389  	return vm_iomap_memory(vma, start, len);
^1da177e4c3f41 drivers/video/fbmem.c            Linus Torvalds    2005-04-16  1390  }

-- 
0-DAY CI Kernel Test Service
https://01.org/lkp



More information about the dri-devel mailing list