Message ID | 20211216232124.1298010-1-harish.chegondi@intel.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | drm/i915: Fix possible NULL pointer dereferences in i9xx_update_wm() | expand |
On Thu, 16 Dec 2021, Harish Chegondi <harish.chegondi@intel.com> wrote: > Check return pointer from intel_crtc_for_plane() before dereferencing > it, as it can be NULL. If you're doing this to satisfy some static analyzer, in these cases the code would read *much* better if you added the NULL check inside intel_crtc_active(). BR, Jani. > > Cc: Jani Nikula <jani.nikula@intel.com> > Cc: Caz Yokoyama <caz.yokoyama@intel.com> > Cc: Radhakrishna Sripada <radhakrishna.sripada@intel.com> > Signed-off-by: Harish Chegondi <harish.chegondi@intel.com> > --- > drivers/gpu/drm/i915/intel_pm.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/drivers/gpu/drm/i915/intel_pm.c b/drivers/gpu/drm/i915/intel_pm.c > index bdf97a8c9ef3..c7a4d8d971d7 100644 > --- a/drivers/gpu/drm/i915/intel_pm.c > +++ b/drivers/gpu/drm/i915/intel_pm.c > @@ -2373,7 +2373,7 @@ static void i9xx_update_wm(struct drm_i915_private *dev_priv) > else > fifo_size = i9xx_get_fifo_size(dev_priv, PLANE_A); > crtc = intel_crtc_for_plane(dev_priv, PLANE_A); > - if (intel_crtc_active(crtc)) { > + if (crtc && intel_crtc_active(crtc)) { > const struct drm_display_mode *pipe_mode = > &crtc->config->hw.pipe_mode; > const struct drm_framebuffer *fb = > @@ -2403,7 +2403,7 @@ static void i9xx_update_wm(struct drm_i915_private *dev_priv) > else > fifo_size = i9xx_get_fifo_size(dev_priv, PLANE_B); > crtc = intel_crtc_for_plane(dev_priv, PLANE_B); > - if (intel_crtc_active(crtc)) { > + if (crtc && intel_crtc_active(crtc)) { > const struct drm_display_mode *pipe_mode = > &crtc->config->hw.pipe_mode; > const struct drm_framebuffer *fb =
diff --git a/drivers/gpu/drm/i915/intel_pm.c b/drivers/gpu/drm/i915/intel_pm.c index bdf97a8c9ef3..c7a4d8d971d7 100644 --- a/drivers/gpu/drm/i915/intel_pm.c +++ b/drivers/gpu/drm/i915/intel_pm.c @@ -2373,7 +2373,7 @@ static void i9xx_update_wm(struct drm_i915_private *dev_priv) else fifo_size = i9xx_get_fifo_size(dev_priv, PLANE_A); crtc = intel_crtc_for_plane(dev_priv, PLANE_A); - if (intel_crtc_active(crtc)) { + if (crtc && intel_crtc_active(crtc)) { const struct drm_display_mode *pipe_mode = &crtc->config->hw.pipe_mode; const struct drm_framebuffer *fb = @@ -2403,7 +2403,7 @@ static void i9xx_update_wm(struct drm_i915_private *dev_priv) else fifo_size = i9xx_get_fifo_size(dev_priv, PLANE_B); crtc = intel_crtc_for_plane(dev_priv, PLANE_B); - if (intel_crtc_active(crtc)) { + if (crtc && intel_crtc_active(crtc)) { const struct drm_display_mode *pipe_mode = &crtc->config->hw.pipe_mode; const struct drm_framebuffer *fb =
Check return pointer from intel_crtc_for_plane() before dereferencing it, as it can be NULL. Cc: Jani Nikula <jani.nikula@intel.com> Cc: Caz Yokoyama <caz.yokoyama@intel.com> Cc: Radhakrishna Sripada <radhakrishna.sripada@intel.com> Signed-off-by: Harish Chegondi <harish.chegondi@intel.com> --- drivers/gpu/drm/i915/intel_pm.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)