[Intel-gfx] [PATCH v2] drm/i915: Fix possible NULL pointer dereferences in i9xx_update_wm()

Jani Nikula jani.nikula at intel.com
Wed Dec 22 08:30:08 UTC 2021


On Fri, 17 Dec 2021, Ville Syrjälä <ville.syrjala at linux.intel.com> wrote:
> On Fri, Dec 17, 2021 at 08:02:55AM -0800, Harish Chegondi wrote:
>> Check return pointer from intel_crtc_for_plane() before dereferencing
>> it, as it can be NULL.
>
> Can't actually bu NULL. But I guess no real harm in having the
> check if it shuts up some static analysis thing.

That's what I figured too, and better have it here than spread around
wherever this is called.

Reviewed-by: Jani Nikula <jani.nikula at intel.com>


>
>> 
>> v2: Moved the NULL check into intel_crtc_active().
>> 
>> 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 | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>> 
>> diff --git a/drivers/gpu/drm/i915/intel_pm.c b/drivers/gpu/drm/i915/intel_pm.c
>> index bdf97a8c9ef3..8b357ec35a4a 100644
>> --- a/drivers/gpu/drm/i915/intel_pm.c
>> +++ b/drivers/gpu/drm/i915/intel_pm.c
>> @@ -877,7 +877,7 @@ static bool intel_crtc_active(struct intel_crtc *crtc)
>>  	 * crtc->state->active once we have proper CRTC states wired up
>>  	 * for atomic.
>>  	 */
>> -	return crtc->active && crtc->base.primary->state->fb &&
>> +	return crtc && crtc->active && crtc->base.primary->state->fb &&
>>  		crtc->config->hw.adjusted_mode.crtc_clock;
>>  }
>>  
>> -- 
>> 2.31.1

-- 
Jani Nikula, Intel Open Source Graphics Center


More information about the Intel-gfx mailing list