apply_dsc_policy_for_stream() decides whether Display Stream Compression
(DSC) should be enabled for a display stream based on display
capabilities, link bandwidth and user overrides.
Smatch reports that apply_dsc_policy_for_stream() dereferences
aconnector->dc_link before checking whether it is NULL.
Add an early NULL check for aconnector->dc_link before the first
dereference and remove the later redundant NULL check in the HDMI_FRL
path.
Fixes: 5903cc8da891 ("drm/amd/display: Extract connector and encoder code to
amdgpu_dm_connector")
Reported-by: Dan Carpenter <[email protected]>
Cc: Roman Li <[email protected]>
Cc: Alex Hung <[email protected]>
Cc: Tom Chung <[email protected]>
Cc: Aurabindo Pillai <[email protected]>
Signed-off-by: Srinivasan Shanmugam <[email protected]>
---
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_connector.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_connector.c
b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_connector.c
index 6143cdcf2a32..64e5c551191f 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_connector.c
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_connector.c
@@ -1210,6 +1210,9 @@ static void apply_dsc_policy_for_stream(struct
amdgpu_dm_connector *aconnector,
drm_connector->display_info.max_dsc_bpp;
struct dc_dsc_config_options dsc_options = {0};
+ if (!aconnector->dc_link)
+ return;
+
dc_dsc_get_default_config_option(dc, &dsc_options);
dsc_options.max_target_bpp_limit_override_x16 =
max_dsc_target_bpp_limit_override * 16;
@@ -1271,7 +1274,7 @@ static void apply_dsc_policy_for_stream(struct
amdgpu_dm_connector *aconnector,
(dsc_caps->is_frl == 1)
? "HDMI FRL RX" : "DP-HDMI PCON");
}
}
- } else if (aconnector->dc_link && sink->sink_signal ==
SIGNAL_TYPE_HDMI_FRL) {
+ } else if (sink->sink_signal == SIGNAL_TYPE_HDMI_FRL) {
frl_verified_link_cap = dc_link_get_frl_link_cap(stream->link);
timing_bw_in_kbps =
dc_bandwidth_in_kbps_from_timing(&stream->timing, DC_LINK_ENCODING_HDMI_FRL);
link_bandwidth_kbps = dc_link_frl_bandwidth_kbps(stream->link,
frl_verified_link_cap->frl_link_rate);
--
2.34.1