drm/i915: avoid potential uninitialized variable use
Subsystems (2)
PATCH 1/1 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.
--- drivers/gpu/drm/i915/intel_ddi.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-)
drivers/gpu/drm/i915/intel_ddi.c +9 -3
@@ -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 ) { *n_entries =ARRAY_SIZE (cnl_ddi_translations_hdmi_1_05V);return cnl_ddi_translations_hdmi_1_05V; - }else + }else { + *n_entries =1 ;MISSING_CASE (voltage); + }return NULL ; }
@@ -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 ) { *n_entries =ARRAY_SIZE (cnl_ddi_translations_dp_1_05V);return cnl_ddi_translations_dp_1_05V; - }else + }else { + *n_entries =1 ;MISSING_CASE (voltage); + }return NULL ; }
@@ -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 ) { *n_entries =ARRAY_SIZE (cnl_ddi_translations_edp_1_05V);return cnl_ddi_translations_edp_1_05V; - }else + }else { + *n_entries =1 ;MISSING_CASE (voltage); + }return NULL ; }else {return cnl_get_buf_trans_dp (dev_priv, n_entries);
Signature · 6 lines
2.9.0 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Patchwork
CI✗ Fi.CI.BAT: failure for drm/i915: avoid potential uninitialized variable use
== Series Details ==
== Series Details ==
Series: drm/i915: avoid potential uninitialized variable use
URL : https://patchwork.freedesktop.org/series/31421/
State : failure
== Summary ==
Series 31421v1 drm/i915: avoid potential uninitialized variable use
https://patchwork.freedesktop.org/api/1.0/series/31421/revisions/1/mbox/
Test kms_frontbuffer_tracking:
Subgroup basic:
pass -> INCOMPLETE (fi-bsw-n3050)
Test drv_module_reload:
Subgroup basic-no-display:
incomplete -> PASS (fi-cfl-s) fdo#103022fdo#103022 https://bugs.freedesktop.org/show_bug.cgi?id=103022
fi-bdw-5557u total:289 pass:268 dwarn:0 dfail:0 fail:0 skip:21 time:457s fi-bdw-gvtdvm total:289 pass:265 dwarn:0 dfail:0 fail:0 skip:24 time:471s fi-blb-e6850 total:289 pass:224 dwarn:1 dfail:0 fail:0 skip:64 time:398s fi-bsw-n3050 total:225 pass:195 dwarn:0 dfail:0 fail:0 skip:29 fi-bwr-2160 total:289 pass:184 dwarn:0 dfail:0 fail:0 skip:105 time:290s fi-bxt-dsi total:289 pass:259 dwarn:0 dfail:0 fail:0 skip:30 time:541s fi-bxt-j4205 total:289 pass:260 dwarn:0 dfail:0 fail:0 skip:29 time:537s fi-byt-j1900 total:289 pass:254 dwarn:1 dfail:0 fail:0 skip:34 time:551s fi-cfl-s total:289 pass:256 dwarn:1 dfail:0 fail:0 skip:32 time:562s fi-cnl-y total:289 pass:262 dwarn:0 dfail:0 fail:0 skip:27 time:643s fi-elk-e7500 total:289 pass:230 dwarn:0 dfail:0 fail:0 skip:59 time:432s fi-glk-1 total:289 pass:261 dwarn:0 dfail:0 fail:0 skip:28 time:605s fi-hsw-4770 total:289 pass:263 dwarn:0 dfail:0 fail:0 skip:26 time:447s fi-hsw-4770r total:289 pass:263 dwarn:0 dfail:0 fail:0 skip:26 time:421s fi-ilk-650 total:289 pass:229 dwarn:0 dfail:0 fail:0 skip:60 time:467s fi-ivb-3520m total:289 pass:261 dwarn:0 dfail:0 fail:0 skip:28 time:513s fi-ivb-3770 total:289 pass:261 dwarn:0 dfail:0 fail:0 skip:28 time:479s fi-kbl-7500u total:289 pass:264 dwarn:1 dfail:0 fail:0 skip:24 time:508s fi-kbl-7560u total:289 pass:270 dwarn:0 dfail:0 fail:0 skip:19 time:589s fi-kbl-7567u total:289 pass:265 dwarn:4 dfail:0 fail:0 skip:20 time:496s fi-kbl-r total:289 pass:262 dwarn:0 dfail:0 fail:0 skip:27 time:595s fi-pnv-d510 total:289 pass:223 dwarn:1 dfail:0 fail:0 skip:65 time:660s fi-skl-6260u total:289 pass:269 dwarn:0 dfail:0 fail:0 skip:20 time:475s fi-skl-6700hq total:289 pass:263 dwarn:0 dfail:0 fail:0 skip:26 time:659s fi-skl-6700k total:289 pass:265 dwarn:0 dfail:0 fail:0 skip:24 time:526s fi-skl-6770hq total:289 pass:269 dwarn:0 dfail:0 fail:0 skip:20 time:525s fi-skl-gvtdvm total:289 pass:266 dwarn:0 dfail:0 fail:0 skip:23 time:474s fi-snb-2520m total:289 pass:251 dwarn:0 dfail:0 fail:0 skip:38 time:586s fi-snb-2600 total:289 pass:250 dwarn:0 dfail:0 fail:0 skip:39 time:439s
fi-byt-n2820 failed to connect after reboot
247cb84af034b8e90ecd22cd69adb13a7a305350 drm-tip: 2017y-10m-05d-06h-44m-09s UTC integration manifest d2275cb06def drm/i915: avoid potential uninitialized variable use
== Logs ==
For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_5909/
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Quoted 23 lines · Arnd Bergmann
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_transfunctions 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 cc9cabfdec38 ("drm/i915/cnl: Move voltage check into ddi buf trans functions.")Signed-off-by Arnd Bergmann <[email protected]>--- drivers/gpu/drm/i915/intel_ddi.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-)drivers/gpu/drm/i915/intel_ddi.c +0
-0
drivers/gpu/drm/i915/intel_ddi.c cnl_get_buf_trans_hdmi(struct drm_i915_private *dev_priv, int *n_entries) · line 608
Quoted 8 lines
drivers/gpu/drm/i915/intel_ddi.c +3
-1@@ -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 ) { *n_entries =ARRAY_SIZE (cnl_ddi_translations_hdmi_1_05V);return cnl_ddi_translations_hdmi_1_05V; - }else + }else { + *n_entries =1 ;MISSING_CASE (voltage); + }
Somewhat meh on this, so added a /* shut up gcc */ comment and merged.
Thanks, Daniel
Quoted 30 lines
drivers/gpu/drm/i915/intel_ddi.c +6
-2return NULL ; }@@ -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 ) { *n_entries =ARRAY_SIZE (cnl_ddi_translations_dp_1_05V);return cnl_ddi_translations_dp_1_05V; - }else + }else { + *n_entries =1 ;MISSING_CASE (voltage); + }return NULL ; }@@ -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 ) { *n_entries =ARRAY_SIZE (cnl_ddi_translations_edp_1_05V);return cnl_ddi_translations_edp_1_05V; - }else + }else { + *n_entries =1 ;MISSING_CASE (voltage); + }return NULL ; }else {return cnl_get_buf_trans_dp (dev_priv, n_entries);Signature · 1 line
2.9.0
Signature · 3 lines
Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch