drm/i915: Skip pixel multiplier x-check if we fail to send the command
Subsystems (2)
PATCH 1/1 drm/i915: Skip pixel multiplier x-check if we fail to send the command
If intel_sdvo_get_value() fails here, val is unitialized and the cross check won't check anything.
--- drivers/gpu/drm/i915/intel_sdvo.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/gpu/drm/i915/intel_sdvo.c +4 -1
@@ -1357,7 +1357,10 @@ static void intel_sdvo_get_config(struct intel_encoder *encoder, }/* Cross check the port pixel multiplier with the sdvo encoder state. */ -intel_sdvo_get_value (intel_sdvo,SDVO_CMD_GET_CLOCK_RATE_MULT , &val,1 ); +if (!intel_sdvo_get_value (intel_sdvo,SDVO_CMD_GET_CLOCK_RATE_MULT , + &val,1 )) +return ; +switch (val) {case SDVO_CLOCK_RATE_MULT_1X : encoder_pixel_multiplier =1 ;
Signature · 1 line
1.8.3.1
Quoted 13 lines · Damien Lespiau
If
intel_sdvo_get_value()fails here, val is unitialized and the cross check won't check anything.Signed-off-by Damien Lespiau <[email protected]>--- drivers/gpu/drm/i915/intel_sdvo.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)drivers/gpu/drm/i915/intel_sdvo.c +0
-0
drivers/gpu/drm/i915/intel_sdvo.c static void intel_sdvo_get_config(struct intel_encoder *encoder, · line 1362
Quoted 7 lines
drivers/gpu/drm/i915/intel_sdvo.c +3
-1@@ -1357,7 +1357,10 @@ static void intel_sdvo_get_config(struct intel_encoder *encoder, }/* Cross check the port pixel multiplier with the sdvo encoder state. */ -intel_sdvo_get_value (intel_sdvo,SDVO_CMD_GET_CLOCK_RATE_MULT , &val,1 ); +if (!intel_sdvo_get_value (intel_sdvo,SDVO_CMD_GET_CLOCK_RATE_MULT , + &val,1 )) +return ;
But now it fails silently instead of being paranoid ... Can we just shut up the tool instead?
-Daniel
Quoted 11 lines
drivers/gpu/drm/i915/intel_sdvo.c +1
-0+switch (val) {case SDVO_CLOCK_RATE_MULT_1X : encoder_pixel_multiplier =1 ;Signature · 6 lines
1.8.3.1 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Signature · 3 lines
Daniel Vetter Software Engineer, Intel Corporation +41 (0) 79 365 57 48 - http://blog.ffwll.ch
Quoted 16 lines · Daniel Vetter
Quoted 15 lines · Damien Lespiau
If
intel_sdvo_get_value()fails here, val is unitialized and the cross check won't check anything.Signed-off-by Damien Lespiau <[email protected]>--- drivers/gpu/drm/i915/intel_sdvo.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)drivers/gpu/drm/i915/intel_sdvo.c +0
-0@@ -1357,7 +1357,10 @@ static void intel_sdvo_get_config(struct intel_encoder *encoder, }
Quoted 8 lines
drivers/gpu/drm/i915/intel_sdvo.c static void intel_sdvo_get_config(struct intel_encoder *encoder, · line 1362
Quoted 5 lines
drivers/gpu/drm/i915/intel_sdvo.c +3
-1/* Cross check the port pixel multiplier with the sdvo encoder state. */ -intel_sdvo_get_value (intel_sdvo,SDVO_CMD_GET_CLOCK_RATE_MULT , &val,1 ); +if (!intel_sdvo_get_value (intel_sdvo,SDVO_CMD_GET_CLOCK_RATE_MULT , + &val,1 )) +return ;But now it fails silently instead of being paranoid ... Can we just shut up the tool instead?
We absolutely can! (and it's done).
Signature · 1 line
Damien
Quoted 26 lines · Damien Lespiau
Quoted 16 lines · Daniel Vetter
Quoted 15 lines · Damien Lespiau
If
intel_sdvo_get_value()fails here, val is unitialized and the cross check won't check anything.Signed-off-by Damien Lespiau <[email protected]>--- drivers/gpu/drm/i915/intel_sdvo.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)drivers/gpu/drm/i915/intel_sdvo.c +0
-0@@ -1357,7 +1357,10 @@ static void intel_sdvo_get_config(struct intel_encoder *encoder, }Quoted 8 lines
drivers/gpu/drm/i915/intel_sdvo.c static void intel_sdvo_get_config(struct intel_encoder *encoder, · line 1362
Quoted 5 lines
drivers/gpu/drm/i915/intel_sdvo.c +3
-1/* Cross check the port pixel multiplier with the sdvo encoder state. */ -intel_sdvo_get_value (intel_sdvo,SDVO_CMD_GET_CLOCK_RATE_MULT , &val,1 ); +if (!intel_sdvo_get_value (intel_sdvo,SDVO_CMD_GET_CLOCK_RATE_MULT , + &val,1 )) +return ;But now it fails silently instead of being paranoid ... Can we just shut up the tool instead?
Quoted 1 line
We absolutely can! (and it's done).
On second thought we could shovel the switch into an if block so that val is only read when written. Since pixel_multiplier is already set to 0 (in case the sdvo device returns garbage) we'll correctly WARN even when get_value fails (and per chance the stack garbage in val is the right value for the pixel multiplier).
-Daniel
Signature · 3 lines
Daniel Vetter Software Engineer, Intel Corporation +41 (0) 79 365 57 48 - http://blog.ffwll.ch
PATCH 1/2 drm/i915: Don't attempt to read an unitialized stack value
If intel_sdvo_get_value() fails here, val is unitialized and the cross check will compare the pipe config multiplier with a bogus value.
Instead, only set encoder_pixel_multiplier when the sdvo command has been successful. The cross check will compare the pipe config value with 0 otherwise.
v2: Do the cross check with the initial value of encoder_pixel_multiplier (0) if the sdvo command fails (and thus keep the warning) (Daniel Vetter)
--- drivers/gpu/drm/i915/intel_sdvo.c | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-)
drivers/gpu/drm/i915/intel_sdvo.c +13 -11
@@ -1357,17 +1357,19 @@ static void intel_sdvo_get_config(struct intel_encoder *encoder, }/* Cross check the port pixel multiplier with the sdvo encoder state. */ -intel_sdvo_get_value (intel_sdvo,SDVO_CMD_GET_CLOCK_RATE_MULT , &val,1 ); -switch (val) { -case SDVO_CLOCK_RATE_MULT_1X : - encoder_pixel_multiplier =1 ; -break ; -case SDVO_CLOCK_RATE_MULT_2X : - encoder_pixel_multiplier =2 ; -break ; -case SDVO_CLOCK_RATE_MULT_4X : - encoder_pixel_multiplier =4 ; -break ; +if (intel_sdvo_get_value (intel_sdvo,SDVO_CMD_GET_CLOCK_RATE_MULT , + &val,1 )) { +switch (val) { +case SDVO_CLOCK_RATE_MULT_1X : + encoder_pixel_multiplier =1 ; +break ; +case SDVO_CLOCK_RATE_MULT_2X : + encoder_pixel_multiplier =2 ; +break ; +case SDVO_CLOCK_RATE_MULT_4X : + encoder_pixel_multiplier =4 ; +break ; + } }if (HAS_PCH_SPLIT (dev))
Signature · 1 line
1.8.3.1
Daniel Vetter
AppliedRe: [PATCH 1/2] drm/i915: Don't attempt to read an unitialized stack value
Quoted 11 lines · Damien Lespiau
If
intel_sdvo_get_value()fails here, val is unitialized and the cross check will compare the pipe config multiplier with a bogus value.Instead, only set
encoder_pixel_multiplierwhen the sdvo command has been successful. The cross check will compare the pipe config value with 0 otherwise.v2: Do the cross check with the initial value of
encoder_pixel_multiplier(0) if the sdvo command fails (and thus keep the warning) (Daniel Vetter)Signed-off-by Damien Lespiau <[email protected]>
Queued for -next, thanks for the patch.
-Daniel
Quoted 46 lines
--- drivers/gpu/drm/i915/intel_sdvo.c | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-)drivers/gpu/drm/i915/intel_sdvo.c +13
-11@@ -1357,17 +1357,19 @@ static void intel_sdvo_get_config(struct intel_encoder *encoder, }/* Cross check the port pixel multiplier with the sdvo encoder state. */ -intel_sdvo_get_value (intel_sdvo,SDVO_CMD_GET_CLOCK_RATE_MULT , &val,1 ); -switch (val) { -case SDVO_CLOCK_RATE_MULT_1X : - encoder_pixel_multiplier =1 ; -break ; -case SDVO_CLOCK_RATE_MULT_2X : - encoder_pixel_multiplier =2 ; -break ; -case SDVO_CLOCK_RATE_MULT_4X : - encoder_pixel_multiplier =4 ; -break ; +if (intel_sdvo_get_value (intel_sdvo,SDVO_CMD_GET_CLOCK_RATE_MULT , + &val,1 )) { +switch (val) { +case SDVO_CLOCK_RATE_MULT_1X : + encoder_pixel_multiplier =1 ; +break ; +case SDVO_CLOCK_RATE_MULT_2X : + encoder_pixel_multiplier =2 ; +break ; +case SDVO_CLOCK_RATE_MULT_4X : + encoder_pixel_multiplier =4 ; +break ; + } }if (HAS_PCH_SPLIT (dev))Signature · 6 lines
1.8.3.1 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Signature · 3 lines
Daniel Vetter Software Engineer, Intel Corporation +41 (0) 79 365 57 48 - http://blog.ffwll.ch