The Linux Kernel Mailing List
 help / color / mirror / Atom feed
* [PATCH] drm/i915/selftests: Fix uninitialized variable
@ 2018-04-24 13:15 Gustavo A. R. Silva
  2018-04-24 13:22 ` Chris Wilson
  0 siblings, 1 reply; 4+ messages in thread
From: Gustavo A. R. Silva @ 2018-04-24 13:15 UTC (permalink / raw)
  To: Chris Wilson, Jani Nikula, Joonas Lahtinen, Rodrigo Vivi,
	David Airlie
  Cc: intel-gfx, dri-devel, linux-kernel, Gustavo A. R. Silva

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(-)

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 */
 
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] drm/i915/selftests: Fix uninitialized variable
  2018-04-24 13:15 [PATCH] drm/i915/selftests: Fix uninitialized variable Gustavo A. R. Silva
@ 2018-04-24 13:22 ` Chris Wilson
  2018-04-24 13:30   ` Gustavo A. R. Silva
  0 siblings, 1 reply; 4+ messages in thread
From: Chris Wilson @ 2018-04-24 13:22 UTC (permalink / raw)
  To: Gustavo A. R. Silva, Jani Nikula, Joonas Lahtinen, Rodrigo Vivi,
	David Airlie
  Cc: intel-gfx, dri-devel, linux-kernel, Gustavo A. R. Silva

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

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] drm/i915/selftests: Fix uninitialized variable
  2018-04-24 13:22 ` Chris Wilson
@ 2018-04-24 13:30   ` Gustavo A. R. Silva
  2018-04-24 13:36     ` Chris Wilson
  0 siblings, 1 reply; 4+ messages in thread
From: Gustavo A. R. Silva @ 2018-04-24 13:30 UTC (permalink / raw)
  To: Chris Wilson, Jani Nikula, Joonas Lahtinen, Rodrigo Vivi,
	David Airlie
  Cc: intel-gfx, dri-devel, linux-kernel



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

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] drm/i915/selftests: Fix uninitialized variable
  2018-04-24 13:30   ` Gustavo A. R. Silva
@ 2018-04-24 13:36     ` Chris Wilson
  0 siblings, 0 replies; 4+ messages in thread
From: Chris Wilson @ 2018-04-24 13:36 UTC (permalink / raw)
  To: Gustavo A. R. Silva, Jani Nikula, Joonas Lahtinen, Rodrigo Vivi,
	David Airlie
  Cc: intel-gfx, dri-devel, linux-kernel

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

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2018-04-24 13:37 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-04-24 13:15 [PATCH] drm/i915/selftests: Fix uninitialized variable Gustavo A. R. Silva
2018-04-24 13:22 ` Chris Wilson
2018-04-24 13:30   ` Gustavo A. R. Silva
2018-04-24 13:36     ` Chris Wilson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox