Commit 7c7dd774 authored by Arnd Bergmann's avatar Arnd Bergmann Committed by Alex Deucher

drm/amd/display: Fix an uninitialized index variable

clang points out that the new logic uses an always-uninitialized
array index:

drivers/gpu/drm/amd/amdgpu/../display/amdgpu_dm/amdgpu_dm.c:9810:38: warning: variable 'i' is uninitialized when used here [-Wuninitialized]
                        timing  = &edid->detailed_timings[i];
                                                          ^
drivers/gpu/drm/amd/amdgpu/../display/amdgpu_dm/amdgpu_dm.c:9720:7: note: initialize the variable 'i' to silence this warning

My best guess is that the index should have been returned by the
parse_hdmi_amd_vsdb() function that walks an array here, so do that.

Fixes: f9b4f20c ("drm/amd/display: Add Freesync HDMI support to DM")
Reviewed-by: default avatarNick Desaulniers <ndesaulniers@google.com>
Signed-off-by: default avatarArnd Bergmann <arnd@arndb.de>
Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
parent 6302aead
...@@ -10033,7 +10033,7 @@ static bool parse_edid_cea(struct amdgpu_dm_connector *aconnector, ...@@ -10033,7 +10033,7 @@ static bool parse_edid_cea(struct amdgpu_dm_connector *aconnector,
return false; return false;
} }
static bool parse_hdmi_amd_vsdb(struct amdgpu_dm_connector *aconnector, static int parse_hdmi_amd_vsdb(struct amdgpu_dm_connector *aconnector,
struct edid *edid, struct amdgpu_hdmi_vsdb_info *vsdb_info) struct edid *edid, struct amdgpu_hdmi_vsdb_info *vsdb_info)
{ {
uint8_t *edid_ext = NULL; uint8_t *edid_ext = NULL;
...@@ -10043,7 +10043,7 @@ static bool parse_hdmi_amd_vsdb(struct amdgpu_dm_connector *aconnector, ...@@ -10043,7 +10043,7 @@ static bool parse_hdmi_amd_vsdb(struct amdgpu_dm_connector *aconnector,
/*----- drm_find_cea_extension() -----*/ /*----- drm_find_cea_extension() -----*/
/* No EDID or EDID extensions */ /* No EDID or EDID extensions */
if (edid == NULL || edid->extensions == 0) if (edid == NULL || edid->extensions == 0)
return false; return -ENODEV;
/* Find CEA extension */ /* Find CEA extension */
for (i = 0; i < edid->extensions; i++) { for (i = 0; i < edid->extensions; i++) {
...@@ -10053,14 +10053,15 @@ static bool parse_hdmi_amd_vsdb(struct amdgpu_dm_connector *aconnector, ...@@ -10053,14 +10053,15 @@ static bool parse_hdmi_amd_vsdb(struct amdgpu_dm_connector *aconnector,
} }
if (i == edid->extensions) if (i == edid->extensions)
return false; return -ENODEV;
/*----- cea_db_offsets() -----*/ /*----- cea_db_offsets() -----*/
if (edid_ext[0] != CEA_EXT) if (edid_ext[0] != CEA_EXT)
return false; return -ENODEV;
valid_vsdb_found = parse_edid_cea(aconnector, edid_ext, EDID_LENGTH, vsdb_info); valid_vsdb_found = parse_edid_cea(aconnector, edid_ext, EDID_LENGTH, vsdb_info);
return valid_vsdb_found;
return valid_vsdb_found ? i : -ENODEV;
} }
void amdgpu_dm_update_freesync_caps(struct drm_connector *connector, void amdgpu_dm_update_freesync_caps(struct drm_connector *connector,
...@@ -10078,7 +10079,6 @@ void amdgpu_dm_update_freesync_caps(struct drm_connector *connector, ...@@ -10078,7 +10079,6 @@ void amdgpu_dm_update_freesync_caps(struct drm_connector *connector,
struct amdgpu_device *adev = drm_to_adev(dev); struct amdgpu_device *adev = drm_to_adev(dev);
bool freesync_capable = false; bool freesync_capable = false;
struct amdgpu_hdmi_vsdb_info vsdb_info = {0}; struct amdgpu_hdmi_vsdb_info vsdb_info = {0};
bool hdmi_valid_vsdb_found = false;
if (!connector->state) { if (!connector->state) {
DRM_ERROR("%s - Connector has no state", __func__); DRM_ERROR("%s - Connector has no state", __func__);
...@@ -10154,8 +10154,8 @@ void amdgpu_dm_update_freesync_caps(struct drm_connector *connector, ...@@ -10154,8 +10154,8 @@ void amdgpu_dm_update_freesync_caps(struct drm_connector *connector,
} }
} }
} else if (edid && amdgpu_dm_connector->dc_sink->sink_signal == SIGNAL_TYPE_HDMI_TYPE_A) { } else if (edid && amdgpu_dm_connector->dc_sink->sink_signal == SIGNAL_TYPE_HDMI_TYPE_A) {
hdmi_valid_vsdb_found = parse_hdmi_amd_vsdb(amdgpu_dm_connector, edid, &vsdb_info); i = parse_hdmi_amd_vsdb(amdgpu_dm_connector, edid, &vsdb_info);
if (hdmi_valid_vsdb_found && vsdb_info.freesync_supported) { if (i >= 0 && vsdb_info.freesync_supported) {
timing = &edid->detailed_timings[i]; timing = &edid->detailed_timings[i];
data = &timing->data.other_data; data = &timing->data.other_data;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment