All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ray Wu <ray.wu@amd.com>
To: <amd-gfx@lists.freedesktop.org>
Cc: Harry Wentland <harry.wentland@amd.com>,
	Leo Li <sunpeng.li@amd.com>,
	Aurabindo Pillai <aurabindo.pillai@amd.com>,
	Roman Li <roman.li@amd.com>, Wayne Lin <wayne.lin@amd.com>,
	Tom Chung <chiahsuan.chung@amd.com>,
	"Fangzhi Zuo" <jerry.zuo@amd.com>,
	Zaeem Mohamed <zaeem.mohamed@amd.com>,
	"Daniel Wheeler" <daniel.wheeler@amd.com>,
	Alex Hung <alex.hung@amd.com>,
	"Peichen Huang" <PeiChen.Huang@amd.com>,
	Cruise Hung <cruise.hung@amd.com>, Ray Wu <ray.wu@amd.com>
Subject: [PATCH 01/11] drm/amd/display: add null check
Date: Wed, 25 Jun 2025 12:02:19 +0800	[thread overview]
Message-ID: <20250625040420.886013-2-ray.wu@amd.com> (raw)
In-Reply-To: <20250625040420.886013-1-ray.wu@amd.com>

From: Peichen Huang <PeiChen.Huang@amd.com>

[WHY]
Prevents null pointer dereferences to enhance function robustness

[HOW]
Adds early null check and return false if invalid.

Reviewed-by: Cruise Hung <cruise.hung@amd.com>
Signed-off-by: Peichen Huang <PeiChen.Huang@amd.com>
Signed-off-by: Ray Wu <ray.wu@amd.com>
---
 drivers/gpu/drm/amd/display/dc/core/dc.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/amd/display/dc/core/dc.c b/drivers/gpu/drm/amd/display/dc/core/dc.c
index 0146ad4e23c8..c744aa9d830f 100644
--- a/drivers/gpu/drm/amd/display/dc/core/dc.c
+++ b/drivers/gpu/drm/amd/display/dc/core/dc.c
@@ -6398,11 +6398,13 @@ unsigned int dc_get_det_buffer_size_from_state(const struct dc_state *context)
  */
 bool dc_get_host_router_index(const struct dc_link *link, unsigned int *host_router_index)
 {
-	struct dc *dc = link->ctx->dc;
+	struct dc *dc;
 
-	if (link->ep_type != DISPLAY_ENDPOINT_USB4_DPIA)
+	if (!link || !host_router_index || link->ep_type != DISPLAY_ENDPOINT_USB4_DPIA)
 		return false;
 
+	dc = link->ctx->dc;
+
 	if (link->link_index < dc->lowest_dpia_link_index)
 		return false;
 
-- 
2.43.0


  reply	other threads:[~2025-06-25  4:05 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-06-25  4:02 [PATCH 00/11] DC Patches June 30 2025 Ray Wu
2025-06-25  4:02 ` Ray Wu [this message]
2025-06-25  4:02 ` [PATCH 02/11] drm/amd/display: Remove unused tunnel BW validation Ray Wu
2025-06-25  4:02 ` [PATCH 03/11] drm/amd/display: prepare for new platform Ray Wu
2025-06-25  4:02 ` [PATCH 04/11] drm/amd/display: Refactor DML21 Initialization and Configuration Ray Wu
2025-06-25  4:02 ` [PATCH 05/11] drm/amd/display: Separate set_gsl from set_gsl_source_select Ray Wu
2025-06-25  4:02 ` [PATCH 06/11] drm/amd/display: Added case for when RR equals panel's max RR using freesync Ray Wu
2025-06-25  4:02 ` [PATCH 07/11] drm/amd/display: Don't allow OLED to go down to fully off Ray Wu
2025-06-25  4:02 ` [PATCH 08/11] drm/amd/display: Fix Link Override Sequencing When Switching Between DIO/HPO Ray Wu
2025-06-25  4:02 ` [PATCH 09/11] drm/amd/display: Add DPP & HUBP reset if power gate enabled on DCN314 Ray Wu
2025-06-25  4:02 ` [PATCH 10/11] drm/amd/display: [FW Promotion] Release 0.1.17.0 Ray Wu
2025-06-25  4:02 ` [PATCH 11/11] drm/amd/display: Promote DAL to 3.2.340 Ray Wu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250625040420.886013-2-ray.wu@amd.com \
    --to=ray.wu@amd.com \
    --cc=PeiChen.Huang@amd.com \
    --cc=alex.hung@amd.com \
    --cc=amd-gfx@lists.freedesktop.org \
    --cc=aurabindo.pillai@amd.com \
    --cc=chiahsuan.chung@amd.com \
    --cc=cruise.hung@amd.com \
    --cc=daniel.wheeler@amd.com \
    --cc=harry.wentland@amd.com \
    --cc=jerry.zuo@amd.com \
    --cc=roman.li@amd.com \
    --cc=sunpeng.li@amd.com \
    --cc=wayne.lin@amd.com \
    --cc=zaeem.mohamed@amd.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.