Commit 83482ca3 authored by Arnd Bergmann's avatar Arnd Bergmann Committed by Daniel Vetter

drm/i915: avoid potential uninitialized variable use

One of the recent changes introduced a warning about
undefined behavior in the sanity checking:

drivers/gpu/drm/i915/intel_ddi.c: In function 'intel_ddi_hdmi_level':
drivers/gpu/drm/i915/intel_ddi.c:654:6: error: 'n_hdmi_entries' may be used uninitialized in this function [-Werror=maybe-uninitialized]

It seems that the new cnl specific get_buf_trans functions
can return uninitialized data if the voltage level is set
to an unexpected value. This changes the code to always return
'1' in that error case, which seems like the safest choice
as we use one less than the number as an array index later on.

Fixes: cc9cabfd ("drm/i915/cnl: Move voltage check into ddi buf trans functions.")
Signed-off-by: default avatarArnd Bergmann <arnd@arndb.de>
[danvet: shut up gcc comment added.]
Signed-off-by: default avatarDaniel Vetter <daniel.vetter@ffwll.ch>
Link: https://patchwork.freedesktop.org/patch/msgid/20171005120835.437022-1-arnd@arndb.de
parent 764d2997
...@@ -602,8 +602,10 @@ cnl_get_buf_trans_hdmi(struct drm_i915_private *dev_priv, int *n_entries) ...@@ -602,8 +602,10 @@ cnl_get_buf_trans_hdmi(struct drm_i915_private *dev_priv, int *n_entries)
} else if (voltage == VOLTAGE_INFO_1_05V) { } else if (voltage == VOLTAGE_INFO_1_05V) {
*n_entries = ARRAY_SIZE(cnl_ddi_translations_hdmi_1_05V); *n_entries = ARRAY_SIZE(cnl_ddi_translations_hdmi_1_05V);
return cnl_ddi_translations_hdmi_1_05V; return cnl_ddi_translations_hdmi_1_05V;
} else } else {
*n_entries = 1; /* shut up gcc */
MISSING_CASE(voltage); MISSING_CASE(voltage);
}
return NULL; return NULL;
} }
...@@ -621,8 +623,10 @@ cnl_get_buf_trans_dp(struct drm_i915_private *dev_priv, int *n_entries) ...@@ -621,8 +623,10 @@ cnl_get_buf_trans_dp(struct drm_i915_private *dev_priv, int *n_entries)
} else if (voltage == VOLTAGE_INFO_1_05V) { } else if (voltage == VOLTAGE_INFO_1_05V) {
*n_entries = ARRAY_SIZE(cnl_ddi_translations_dp_1_05V); *n_entries = ARRAY_SIZE(cnl_ddi_translations_dp_1_05V);
return cnl_ddi_translations_dp_1_05V; return cnl_ddi_translations_dp_1_05V;
} else } else {
*n_entries = 1; /* shut up gcc */
MISSING_CASE(voltage); MISSING_CASE(voltage);
}
return NULL; return NULL;
} }
...@@ -641,8 +645,10 @@ cnl_get_buf_trans_edp(struct drm_i915_private *dev_priv, int *n_entries) ...@@ -641,8 +645,10 @@ cnl_get_buf_trans_edp(struct drm_i915_private *dev_priv, int *n_entries)
} else if (voltage == VOLTAGE_INFO_1_05V) { } else if (voltage == VOLTAGE_INFO_1_05V) {
*n_entries = ARRAY_SIZE(cnl_ddi_translations_edp_1_05V); *n_entries = ARRAY_SIZE(cnl_ddi_translations_edp_1_05V);
return cnl_ddi_translations_edp_1_05V; return cnl_ddi_translations_edp_1_05V;
} else } else {
*n_entries = 1; /* shut up gcc */
MISSING_CASE(voltage); MISSING_CASE(voltage);
}
return NULL; return NULL;
} else { } else {
return cnl_get_buf_trans_dp(dev_priv, n_entries); return cnl_get_buf_trans_dp(dev_priv, n_entries);
......
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