[Intel-gfx] [PATCH] drm/i915: Fix possible NULL pointer dereferences in i9xx_update_wm()
Jani Nikula
jani.nikula at intel.com
Fri Dec 17 10:18:15 UTC 2021
On Thu, 16 Dec 2021, Harish Chegondi <harish.chegondi at 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 at intel.com>
> Cc: Caz Yokoyama <caz.yokoyama at intel.com>
> Cc: Radhakrishna Sripada <radhakrishna.sripada at intel.com>
> Signed-off-by: Harish Chegondi <harish.chegondi at 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 =
--
Jani Nikula, Intel Open Source Graphics Center
More information about the Intel-gfx
mailing list