From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 4B8CCC433F5 for ; Fri, 17 Dec 2021 10:18:26 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id D1DDA10FEA1; Fri, 17 Dec 2021 10:18:25 +0000 (UTC) Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by gabe.freedesktop.org (Postfix) with ESMTPS id BBB6A10FEA1 for ; Fri, 17 Dec 2021 10:18:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1639736303; x=1671272303; h=from:to:cc:subject:in-reply-to:references:date: message-id:mime-version; bh=VFvn6gfXxRSpgvVJh5gSHRqHLoXyVDESid8961NHTSo=; b=bec/T40KV2o1NODGPtqWpORV5lLpwNEd4zgNRKgQtwwWOKb1Vi67tsbp OoYsbP+95ur4yOkczJYRXwmZTAckKM6KttO31X3nD3K9UiJSujNBBXdTK BxpBbv5uWsShTLlPImRvBH4AAYlIWkpKJRfBDIewzxACut/3sprm5Qs+3 QHw2Ol5KRVCooQ2bfxr/vsye7doExDFLAttAloZ8Yioa4UFQcGFph+am4 vs9M2h7mAhLLBqczegb+mMaksWm5/nFP6YfHaJ1NBsAaBWGplGt1uFzWM MdRAAaisIO5o/byFDgKgc03mXSszBWnipwPHlVqvdeRACDTsMuUE8ZESH g==; X-IronPort-AV: E=McAfee;i="6200,9189,10200"; a="219740930" X-IronPort-AV: E=Sophos;i="5.88,213,1635231600"; d="scan'208";a="219740930" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Dec 2021 02:18:23 -0800 X-IronPort-AV: E=Sophos;i="5.88,213,1635231600"; d="scan'208";a="519692454" Received: from kmcgonig-mobl1.ger.corp.intel.com (HELO localhost) ([10.252.8.181]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Dec 2021 02:18:20 -0800 From: Jani Nikula To: Harish Chegondi , intel-gfx@lists.freedesktop.org In-Reply-To: <20211216232124.1298010-1-harish.chegondi@intel.com> Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo References: <20211216232124.1298010-1-harish.chegondi@intel.com> Date: Fri, 17 Dec 2021 12:18:15 +0200 Message-ID: <874k77357c.fsf@intel.com> MIME-Version: 1.0 Content-Type: text/plain Subject: Re: [Intel-gfx] [PATCH] drm/i915: Fix possible NULL pointer dereferences in i9xx_update_wm() X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" On Thu, 16 Dec 2021, Harish Chegondi 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 > Cc: Caz Yokoyama > Cc: Radhakrishna Sripada > Signed-off-by: Harish Chegondi > --- > 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