diff mbox

drm/i915/selftests: Fix uninitialized variable

Message ID 20180424131545.GA4053@embeddedor.com (mailing list archive)
State New, archived
Headers show

Commit Message

Gustavo A. R. Silva April 24, 2018, 1:15 p.m. UTC
There is a potential execution path in which variable err is
returned without being properly initialized previously.

Fix this by initializing variable err to 0.

Addresses-Coverity-ID: 1468362 ("Uninitialized scalar variable")
Fixes: f4ecfbfc32ed ("drm/i915: Check whitelist registers across resets")
Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
---
 drivers/gpu/drm/i915/selftests/intel_workarounds.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Gustavo A. R. Silva April 24, 2018, 1:30 p.m. UTC | #1
On 04/24/2018 08:22 AM, Chris Wilson wrote:
> Quoting Gustavo A. R. Silva (2018-04-24 14:15:45)
>> There is a potential execution path in which variable err is
>> returned without being properly initialized previously.
>>
>> Fix this by initializing variable err to 0.
> 
> err is only returned along an error path, returning 0 would not be
> useful. Which path? All the error paths look correct to me.
> -Chris
> 

If the following two conditions take the false branch then the function 
returns err with a random stack value:

if (intel_has_reset_engine(i915)) {
		...
}

if (intel_has_gpu_reset(i915)) {
		...
}

Thanks
--
Gustavo
Chris Wilson April 24, 2018, 1:36 p.m. UTC | #2
Quoting Gustavo A. R. Silva (2018-04-24 14:30:58)
> 
> 
> On 04/24/2018 08:22 AM, Chris Wilson wrote:
> > Quoting Gustavo A. R. Silva (2018-04-24 14:15:45)
> >> There is a potential execution path in which variable err is
> >> returned without being properly initialized previously.
> >>
> >> Fix this by initializing variable err to 0.
> > 
> > err is only returned along an error path, returning 0 would not be
> > useful. Which path? All the error paths look correct to me.
> > -Chris
> > 
> 
> If the following two conditions take the false branch then the function 
> returns err with a random stack value:


It would help if I read the right function. Ok,
Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
-Chris
Chris Wilson April 24, 2018, 7:42 p.m. UTC | #3
Quoting Patchwork (2018-04-24 20:02:06)
> == Series Details ==
> 
> Series: drm/i915/selftests: Fix uninitialized variable
> URL   : https://patchwork.freedesktop.org/series/42194/
> State : failure
> 
> == Summary ==
> 
> = CI Bug Log - changes from CI_DRM_4087_full -> Patchwork_8790_full =
> 
> == Summary - FAILURE ==
> 
>   Serious unknown changes coming with Patchwork_8790_full absolutely need to be
>   verified manually.
>   
>   If you think the reported changes have nothing to do with the changes
>   introduced in Patchwork_8790_full, please notify your bug team to allow them
>   to document this new failure mode, which will reduce false positives in CI.
> 
>   External URL: https://patchwork.freedesktop.org/api/1.0/series/42194/revisions/1/mbox/
> 
> == Possible new issues ==
> 
>   Here are the unknown changes that may have been introduced in Patchwork_8790_full:
> 
>   === IGT changes ===
> 
>     ==== Possible regressions ====
> 
>     igt@prime_busy@wait-before-blt:
>       shard-glk:          PASS -> FAIL

Not related (obviously!)

Thanks for the fixup, applied.
-Chris
Gustavo A. R. Silva April 24, 2018, 7:43 p.m. UTC | #4
On 04/24/2018 02:42 PM, Chris Wilson wrote:
> Quoting Patchwork (2018-04-24 20:02:06)
>> == Series Details ==
>>
>> Series: drm/i915/selftests: Fix uninitialized variable
>> URL   : https://patchwork.freedesktop.org/series/42194/
>> State : failure
>>
>> == Summary ==
>>
>> = CI Bug Log - changes from CI_DRM_4087_full -> Patchwork_8790_full =
>>
>> == Summary - FAILURE ==
>>
>>    Serious unknown changes coming with Patchwork_8790_full absolutely need to be
>>    verified manually.
>>    
>>    If you think the reported changes have nothing to do with the changes
>>    introduced in Patchwork_8790_full, please notify your bug team to allow them
>>    to document this new failure mode, which will reduce false positives in CI.
>>
>>    External URL: https://patchwork.freedesktop.org/api/1.0/series/42194/revisions/1/mbox/
>>
>> == Possible new issues ==
>>
>>    Here are the unknown changes that may have been introduced in Patchwork_8790_full:
>>
>>    === IGT changes ===
>>
>>      ==== Possible regressions ====
>>
>>      igt@prime_busy@wait-before-blt:
>>        shard-glk:          PASS -> FAIL
> 
> Not related (obviously!)
> 
> Thanks for the fixup, applied.
> -Chris
> 

Yep. I noticed that.

Glad to help. :)

Thanks
--
Gustavo
diff mbox

Patch

diff --git a/drivers/gpu/drm/i915/selftests/intel_workarounds.c b/drivers/gpu/drm/i915/selftests/intel_workarounds.c
index 5455b26..17444a3 100644
--- a/drivers/gpu/drm/i915/selftests/intel_workarounds.c
+++ b/drivers/gpu/drm/i915/selftests/intel_workarounds.c
@@ -239,7 +239,7 @@  static int live_reset_whitelist(void *arg)
 	struct intel_engine_cs *engine = i915->engine[RCS];
 	struct i915_gpu_error *error = &i915->gpu_error;
 	struct whitelist w;
-	int err;
+	int err = 0;
 
 	/* If we reset the gpu, we should not lose the RING_NONPRIV */