Hi, kernel test robot noticed the following build warnings:
https://git-scm.com/docs/git-format-patch#_base_tree_information] url: https://github.com/intel-lab-lkp/linux/commits/sunpeng-li-amd-com/drm-amd-display-Implement-prepare_vblank_enable-callback/20251202-072501 base: https://gitlab.freedesktop.org/drm/i915/kernel.git for-linux-next-fixes patch link: https://lore.kernel.org/r/20251201231807.287414-1-sunpeng.li%40amd.com patch subject: [PATCH v2 1/2] drm: Introduce drm_crtc_vblank_prepare() config: nios2-randconfig-r071-20251204 (https://download.01.org/0day-ci/archive/20251204/[email protected]/config) compiler: nios2-linux-gcc (GCC) 8.5.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 <[email protected]> | Reported-by: Dan Carpenter <[email protected]> | Closes: https://lore.kernel.org/r/[email protected]/ smatch warnings: drivers/gpu/drm/drm_vblank.c:1527 drm_crtc_vblank_on_config() warn: variable dereferenced before check 'crtc' (see line 1519) vim +/crtc +1527 drivers/gpu/drm/drm_vblank.c 0d5040e406d2c44 Hamza Mahfooz 2024-07-25 1516 void drm_crtc_vblank_on_config(struct drm_crtc *crtc, 0d5040e406d2c44 Hamza Mahfooz 2024-07-25 1517 const struct drm_vblank_crtc_config *config) 3ed4351a83ca05d Simona Vetter 2017-05-31 1518 { 3ed4351a83ca05d Simona Vetter 2017-05-31 @1519 struct drm_device *dev = crtc->dev; 3ed4351a83ca05d Simona Vetter 2017-05-31 1520 unsigned int pipe = drm_crtc_index(crtc); ^^^^ Unchecked dereference. I'm pretty certain crtc can't be NULL. d12e36494dc2bf2 Ville Syrjälä 2024-04-08 1521 struct drm_vblank_crtc *vblank = drm_crtc_vblank_crtc(crtc); 38bd1e412d0aa4b Leo Li 2025-12-01 1522 int ret; 3ed4351a83ca05d Simona Vetter 2017-05-31 1523 5a4784f49b2dcff Sam Ravnborg 2020-05-23 1524 if (drm_WARN_ON(dev, pipe >= dev->num_crtcs)) 3ed4351a83ca05d Simona Vetter 2017-05-31 1525 return; 3ed4351a83ca05d Simona Vetter 2017-05-31 1526 38bd1e412d0aa4b Leo Li 2025-12-01 @1527 if (crtc) { ^^^^^^^^^^^ So this NULL check is too late, and can be removed. 38bd1e412d0aa4b Leo Li 2025-12-01 1528 ret = drm_crtc_vblank_prepare(crtc); 38bd1e412d0aa4b Leo Li 2025-12-01 1529 drm_WARN_ON(dev, ret); 38bd1e412d0aa4b Leo Li 2025-12-01 1530 if (ret) 38bd1e412d0aa4b Leo Li 2025-12-01 1531 return; 38bd1e412d0aa4b Leo Li 2025-12-01 1532 } 38bd1e412d0aa4b Leo Li 2025-12-01 1533 92cc68e35863c1c Lyude Paul 2020-07-20 1534 spin_lock_irq(&dev->vbl_lock); 02149a76d32bd8f Sam Ravnborg 2020-05-23 1535 drm_dbg_vbl(dev, "crtc %d, vblank enabled %d, inmodeset %d\n", 3ed4351a83ca05d Simona Vetter 2017-05-31 1536 pipe, vblank->enabled, vblank->inmodeset); 3ed4351a83ca05d Simona Vetter 2017-05-31 1537 0d5040e406d2c44 Hamza Mahfooz 2024-07-25 1538 vblank->config = *config; 0d5040e406d2c44 Hamza Mahfooz 2024-07-25 1539 3ed4351a83ca05d Simona Vetter 2017-05-31 1540 /* Drop our private "prevent drm_vblank_get" refcount */ 3ed4351a83ca05d Simona Vetter 2017-05-31 1541 if (vblank->inmodeset) { 3ed4351a83ca05d Simona Vetter 2017-05-31 1542 atomic_dec(&vblank->refcount); 3ed4351a83ca05d Simona Vetter 2017-05-31 1543 vblank->inmodeset = 0; 3ed4351a83ca05d Simona Vetter 2017-05-31 1544 } 3ed4351a83ca05d Simona Vetter 2017-05-31 1545 3ed4351a83ca05d Simona Vetter 2017-05-31 1546 drm_reset_vblank_timestamp(dev, pipe); 3ed4351a83ca05d Simona Vetter 2017-05-31 1547 3ed4351a83ca05d Simona Vetter 2017-05-31 1548 /* 3ed4351a83ca05d Simona Vetter 2017-05-31 1549 * re-enable interrupts if there are users left, or the 3ed4351a83ca05d Simona Vetter 2017-05-31 1550 * user wishes vblank interrupts to be enabled all the time. 3ed4351a83ca05d Simona Vetter 2017-05-31 1551 */ 0d5040e406d2c44 Hamza Mahfooz 2024-07-25 1552 if (atomic_read(&vblank->refcount) != 0 || !vblank->config.offdelay_ms) 5a4784f49b2dcff Sam Ravnborg 2020-05-23 1553 drm_WARN_ON(dev, drm_vblank_enable(dev, pipe)); 92cc68e35863c1c Lyude Paul 2020-07-20 1554 spin_unlock_irq(&dev->vbl_lock); 3ed4351a83ca05d Simona Vetter 2017-05-31 1555 } -- 0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki
