From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3A5571DEFE3; Tue, 8 Oct 2024 12:23:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728390216; cv=none; b=W8ppgU7PC8M4BCr/KbhFnmcpNKntQbSFFbry0yEggOoInXoFhZuPKbns1mqjxINA8cS6IIqIlR8X7+8WKDDKa8i9UeUIMEa2S4nu8MugQP45vlas62G0RIfYK3I5QsKx8WBn8z1lvf8FJM3/BKS5HKxnnoRLg/mZpOz9QZtNYCE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728390216; c=relaxed/simple; bh=fMSMNwf8B5DZE6aWDOmcHb91ZY4VcAJmwSmRCfVFTXc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=NlgHdg+xoDGWMi+mfHb7XrxHFNYM9UyRU/hMPBwEi5dqE2jm/f0zK+ljHRvc0+Xv/lbgQsvkUpGWqseSgFmWvvOLaRIwAD7B4/j/ZhBtbAGFxq5fCvPmKhMalcLvMNuR8Vr5gP0kg+Hcn9D0NfyBc9XAvd597JonYmHMyvhAstA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=p0WXp5aB; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="p0WXp5aB" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 44FB9C4CECC; Tue, 8 Oct 2024 12:23:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1728390215; bh=fMSMNwf8B5DZE6aWDOmcHb91ZY4VcAJmwSmRCfVFTXc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=p0WXp5aBMrQ2NhcKnMzPouAoypR+A29bUWQLunMQd66FwNFiotDjR16p2+hwlKuv2 v/B6Gu4buzc+mZeayOawZDL7nBbmqIhMHRIJhFKkWEkCs8aAUqXa9H9m5nPVglLxHc bYRY20h+rs9ycmy55ROED6nXgQ16NqdTZGazGCJs= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Tom Chung , Rodrigo Siqueira , Roman Li , Alex Hung , Aurabindo Pillai , Harry Wentland , Srinivasan Shanmugam , Alex Deucher , Sasha Levin Subject: [PATCH 6.10 193/482] drm/amd/display: Add null check for afb in amdgpu_dm_plane_handle_cursor_update (v2) Date: Tue, 8 Oct 2024 14:04:16 +0200 Message-ID: <20241008115655.898845164@linuxfoundation.org> X-Mailer: git-send-email 2.46.2 In-Reply-To: <20241008115648.280954295@linuxfoundation.org> References: <20241008115648.280954295@linuxfoundation.org> User-Agent: quilt/0.67 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.10-stable review patch. If anyone has any objections, please let me know. ------------------ From: Srinivasan Shanmugam [ Upstream commit cd9e9e0852d501f169aa3bb34e4b413d2eb48c37 ] This commit adds a null check for the 'afb' variable in the amdgpu_dm_plane_handle_cursor_update function. Previously, 'afb' was assumed to be null, but was used later in the code without a null check. This could potentially lead to a null pointer dereference. Changes since v1: - Moved the null check for 'afb' to the line where 'afb' is used. (Alex) Fixes the below: drivers/gpu/drm/amd/amdgpu/../display/amdgpu_dm/amdgpu_dm_plane.c:1298 amdgpu_dm_plane_handle_cursor_update() error: we previously assumed 'afb' could be null (see line 1252) Cc: Tom Chung Cc: Rodrigo Siqueira Cc: Roman Li Cc: Alex Hung Cc: Aurabindo Pillai Cc: Harry Wentland Co-developed-by: Alex Hung Signed-off-by: Alex Hung Signed-off-by: Srinivasan Shanmugam Reviewed-by: Tom Chung Signed-off-by: Alex Deucher Signed-off-by: Sasha Levin --- drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_plane.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_plane.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_plane.c index 7d47acdd11d55..fe7a99aee47dd 100644 --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_plane.c +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_plane.c @@ -1285,7 +1285,8 @@ void amdgpu_dm_plane_handle_cursor_update(struct drm_plane *plane, adev->dm.dc->caps.color.dpp.gamma_corr) attributes.attribute_flags.bits.ENABLE_CURSOR_DEGAMMA = 1; - attributes.pitch = afb->base.pitches[0] / afb->base.format->cpp[0]; + if (afb) + attributes.pitch = afb->base.pitches[0] / afb->base.format->cpp[0]; if (crtc_state->stream) { mutex_lock(&adev->dm.dc_lock); -- 2.43.0