Message ID | 20200819043409.26010-4-nischal.varide@intel.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | [1/5] Critical-KclockWork-Fixes-intel_atomi.c-PossibleNull | expand |
On 2020-08-19 at 10:04:08 +0530, Nischal Varide wrote: > This patch fixes the Critical Klock work Error and in this case a > Possible Null Pointer Dereference has been addressed with a Null check > before dereferencing > > Signed-off-by: Nischal Varide <nischal.varide@intel.com> > --- > drivers/gpu/drm/i915/display/intel_tv.c | 17 ++++++++++------- > 1 file changed, 10 insertions(+), 7 deletions(-) > > diff --git a/drivers/gpu/drm/i915/display/intel_tv.c b/drivers/gpu/drm/i915/display/intel_tv.c > index 777032d9697b..5600d146ae81 100644 > --- a/drivers/gpu/drm/i915/display/intel_tv.c > +++ b/drivers/gpu/drm/i915/display/intel_tv.c > @@ -1836,17 +1836,20 @@ static int intel_tv_atomic_check(struct drm_connector *connector, > struct drm_connector_state *old_state; > > new_state = drm_atomic_get_new_connector_state(state, connector); > - if (!new_state->crtc) > - return 0; > - > old_state = drm_atomic_get_old_connector_state(state, connector); > new_crtc_state = drm_atomic_get_new_crtc_state(state, new_state->crtc); > > + if (!(old_state && new_state && new_crtc_state)) > + return 0; > + > + if (!new_state->crtc) > + return 0; > + > if (old_state->tv.mode != new_state->tv.mode || > - old_state->tv.margins.left != new_state->tv.margins.left || > - old_state->tv.margins.right != new_state->tv.margins.right || > - old_state->tv.margins.top != new_state->tv.margins.top || > - old_state->tv.margins.bottom != new_state->tv.margins.bottom) { > + old_state->tv.margins.left != new_state->tv.margins.left || > + old_state->tv.margins.right != new_state->tv.margins.right || > + old_state->tv.margins.top != new_state->tv.margins.top || > + old_state->tv.margins.bottom != new_state->tv.margins.bottom) { This seems unwanted changes. Thanks, Anshuman. > /* Force a modeset. */ > > new_crtc_state->connectors_changed = true; > -- > 2.26.0 > > _______________________________________________ > Intel-gfx mailing list > Intel-gfx@lists.freedesktop.org > https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Hi Nischal, Thank you for the patch! Perhaps something to improve: url: https://github.com/0day-ci/linux/commits/Nischal-Varide/Critical-KclockWork-Fixes-intel_atomi-c-PossibleNull/20200819-193249 base: git://anongit.freedesktop.org/drm-intel for-linux-next config: i386-randconfig-m021-20200824 (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> Reported-by: Dan Carpenter <dan.carpenter@oracle.com> smatch warnings: drivers/gpu/drm/i915/display/intel_tv.c:1842 intel_tv_atomic_check() warn: variable dereferenced before check 'new_state' (see line 1840) # https://github.com/0day-ci/linux/commit/6fb528c1b424d3c8095085afa7e777ac5502450b git remote add linux-review https://github.com/0day-ci/linux git fetch --no-tags linux-review Nischal-Varide/Critical-KclockWork-Fixes-intel_atomi-c-PossibleNull/20200819-193249 git checkout 6fb528c1b424d3c8095085afa7e777ac5502450b vim +/new_state +1842 drivers/gpu/drm/i915/display/intel_tv.c 0e891b3f447f4d drivers/gpu/drm/i915/intel_tv.c Maarten Lankhorst 2017-04-10 1831 static int intel_tv_atomic_check(struct drm_connector *connector, 6f3b62781bbd26 drivers/gpu/drm/i915/intel_tv.c Sean Paul 2019-06-11 1832 struct drm_atomic_state *state) 0e891b3f447f4d drivers/gpu/drm/i915/intel_tv.c Maarten Lankhorst 2017-04-10 1833 { 6f3b62781bbd26 drivers/gpu/drm/i915/intel_tv.c Sean Paul 2019-06-11 1834 struct drm_connector_state *new_state; 0e891b3f447f4d drivers/gpu/drm/i915/intel_tv.c Maarten Lankhorst 2017-04-10 1835 struct drm_crtc_state *new_crtc_state; 0e891b3f447f4d drivers/gpu/drm/i915/intel_tv.c Maarten Lankhorst 2017-04-10 1836 struct drm_connector_state *old_state; 0e891b3f447f4d drivers/gpu/drm/i915/intel_tv.c Maarten Lankhorst 2017-04-10 1837 6f3b62781bbd26 drivers/gpu/drm/i915/intel_tv.c Sean Paul 2019-06-11 1838 new_state = drm_atomic_get_new_connector_state(state, connector); 6f3b62781bbd26 drivers/gpu/drm/i915/intel_tv.c Sean Paul 2019-06-11 1839 old_state = drm_atomic_get_old_connector_state(state, connector); 6f3b62781bbd26 drivers/gpu/drm/i915/intel_tv.c Sean Paul 2019-06-11 @1840 new_crtc_state = drm_atomic_get_new_crtc_state(state, new_state->crtc); ^^^^^^^^^^^^^^^ Dereference 0e891b3f447f4d drivers/gpu/drm/i915/intel_tv.c Maarten Lankhorst 2017-04-10 1841 6fb528c1b424d3 drivers/gpu/drm/i915/display/intel_tv.c Nischal Varide 2020-08-19 @1842 if (!(old_state && new_state && new_crtc_state)) ^^^^^^^^^ Checked too late 6fb528c1b424d3 drivers/gpu/drm/i915/display/intel_tv.c Nischal Varide 2020-08-19 1843 return 0; 6fb528c1b424d3 drivers/gpu/drm/i915/display/intel_tv.c Nischal Varide 2020-08-19 1844 6fb528c1b424d3 drivers/gpu/drm/i915/display/intel_tv.c Nischal Varide 2020-08-19 1845 if (!new_state->crtc) 6fb528c1b424d3 drivers/gpu/drm/i915/display/intel_tv.c Nischal Varide 2020-08-19 1846 return 0; 6fb528c1b424d3 drivers/gpu/drm/i915/display/intel_tv.c Nischal Varide 2020-08-19 1847 0e891b3f447f4d drivers/gpu/drm/i915/intel_tv.c Maarten Lankhorst 2017-04-10 1848 if (old_state->tv.mode != new_state->tv.mode || 0e891b3f447f4d drivers/gpu/drm/i915/intel_tv.c Maarten Lankhorst 2017-04-10 1849 old_state->tv.margins.left != new_state->tv.margins.left || 0e891b3f447f4d drivers/gpu/drm/i915/intel_tv.c Maarten Lankhorst 2017-04-10 1850 old_state->tv.margins.right != new_state->tv.margins.right || 0e891b3f447f4d drivers/gpu/drm/i915/intel_tv.c Maarten Lankhorst 2017-04-10 1851 old_state->tv.margins.top != new_state->tv.margins.top || 0e891b3f447f4d drivers/gpu/drm/i915/intel_tv.c Maarten Lankhorst 2017-04-10 1852 old_state->tv.margins.bottom != new_state->tv.margins.bottom) { 0e891b3f447f4d drivers/gpu/drm/i915/intel_tv.c Maarten Lankhorst 2017-04-10 1853 /* Force a modeset. */ 0e891b3f447f4d drivers/gpu/drm/i915/intel_tv.c Maarten Lankhorst 2017-04-10 1854 0e891b3f447f4d drivers/gpu/drm/i915/intel_tv.c Maarten Lankhorst 2017-04-10 1855 new_crtc_state->connectors_changed = true; 0e891b3f447f4d drivers/gpu/drm/i915/intel_tv.c Maarten Lankhorst 2017-04-10 1856 } 0e891b3f447f4d drivers/gpu/drm/i915/intel_tv.c Maarten Lankhorst 2017-04-10 1857 0e891b3f447f4d drivers/gpu/drm/i915/intel_tv.c Maarten Lankhorst 2017-04-10 1858 return 0; 0e891b3f447f4d drivers/gpu/drm/i915/intel_tv.c Maarten Lankhorst 2017-04-10 1859 } --- 0-DAY CI Kernel Test Service, Intel Corporation https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
diff --git a/drivers/gpu/drm/i915/display/intel_tv.c b/drivers/gpu/drm/i915/display/intel_tv.c index 777032d9697b..5600d146ae81 100644 --- a/drivers/gpu/drm/i915/display/intel_tv.c +++ b/drivers/gpu/drm/i915/display/intel_tv.c @@ -1836,17 +1836,20 @@ static int intel_tv_atomic_check(struct drm_connector *connector, struct drm_connector_state *old_state; new_state = drm_atomic_get_new_connector_state(state, connector); - if (!new_state->crtc) - return 0; - old_state = drm_atomic_get_old_connector_state(state, connector); new_crtc_state = drm_atomic_get_new_crtc_state(state, new_state->crtc); + if (!(old_state && new_state && new_crtc_state)) + return 0; + + if (!new_state->crtc) + return 0; + if (old_state->tv.mode != new_state->tv.mode || - old_state->tv.margins.left != new_state->tv.margins.left || - old_state->tv.margins.right != new_state->tv.margins.right || - old_state->tv.margins.top != new_state->tv.margins.top || - old_state->tv.margins.bottom != new_state->tv.margins.bottom) { + old_state->tv.margins.left != new_state->tv.margins.left || + old_state->tv.margins.right != new_state->tv.margins.right || + old_state->tv.margins.top != new_state->tv.margins.top || + old_state->tv.margins.bottom != new_state->tv.margins.bottom) { /* Force a modeset. */ new_crtc_state->connectors_changed = true;
This patch fixes the Critical Klock work Error and in this case a Possible Null Pointer Dereference has been addressed with a Null check before dereferencing Signed-off-by: Nischal Varide <nischal.varide@intel.com> --- drivers/gpu/drm/i915/display/intel_tv.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-)