drivers/gpu/drm/amd/amdgpu/../display/amdgpu_dm/amdgpu_dm.c:4765 dm_atomic_check_plane_state_fb() error: 'crtc_state' dereferencing possible ERR_PTR()

From: Dan Carpenter
Date: Mon Mar 12 2018 - 13:25:58 EST


tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head: 0c8efd610b58cb23cefdfa12015799079aef94ae
commit: 36cc549d59864b7161f0e23d710c1c4d1b9cf022 drm/amd/display: disable CRTCs with NULL FB on their primary plane (V2)

smatch warnings:
drivers/gpu/drm/amd/amdgpu/../display/amdgpu_dm/amdgpu_dm.c:4765 dm_atomic_check_plane_state_fb() error: 'crtc_state' dereferencing possible ERR_PTR()

# https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=36cc549d59864b7161f0e23d710c1c4d1b9cf022
git remote add linus https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
git remote update linus
git checkout 36cc549d59864b7161f0e23d710c1c4d1b9cf022
vim +/crtc_state +4765 drivers/gpu/drm/amd/amdgpu/../display/amdgpu_dm/amdgpu_dm.c

62f55537 Andrey Grodzovsky 2017-08-18 4748
36cc549d Shirish S 2018-02-28 4749 static int dm_atomic_check_plane_state_fb(struct drm_atomic_state *state,
36cc549d Shirish S 2018-02-28 4750 struct drm_crtc *crtc)
36cc549d Shirish S 2018-02-28 4751 {
36cc549d Shirish S 2018-02-28 4752 struct drm_plane *plane;
36cc549d Shirish S 2018-02-28 4753 struct drm_crtc_state *crtc_state;
36cc549d Shirish S 2018-02-28 4754
36cc549d Shirish S 2018-02-28 4755 WARN_ON(!drm_atomic_get_new_crtc_state(state, crtc));
36cc549d Shirish S 2018-02-28 4756
36cc549d Shirish S 2018-02-28 4757 drm_for_each_plane_mask(plane, state->dev, crtc->state->plane_mask) {
36cc549d Shirish S 2018-02-28 4758 struct drm_plane_state *plane_state =
36cc549d Shirish S 2018-02-28 4759 drm_atomic_get_plane_state(state, plane);
36cc549d Shirish S 2018-02-28 4760
36cc549d Shirish S 2018-02-28 4761 if (IS_ERR(plane_state))
36cc549d Shirish S 2018-02-28 4762 return -EDEADLK;
36cc549d Shirish S 2018-02-28 4763
36cc549d Shirish S 2018-02-28 4764 crtc_state = drm_atomic_get_crtc_state(plane_state->state, crtc);
36cc549d Shirish S 2018-02-28 @4765 if (crtc->primary == plane && crtc_state->active) {
36cc549d Shirish S 2018-02-28 4766 if (!plane_state->fb)
36cc549d Shirish S 2018-02-28 4767 return -EINVAL;
36cc549d Shirish S 2018-02-28 4768 }
36cc549d Shirish S 2018-02-28 4769 }
36cc549d Shirish S 2018-02-28 4770 return 0;
36cc549d Shirish S 2018-02-28 4771 }
36cc549d Shirish S 2018-02-28 4772

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