diff mbox

drm/i915: initialize ret in i915_gem_evict_something

Message ID 1483627291-7532-1-git-send-email-matthew.auld@intel.com (mailing list archive)
State New, archived
Headers show

Commit Message

Matthew Auld Jan. 5, 2017, 2:41 p.m. UTC
If we find a suitable victim node on our first pass, then ret
will be uninitialized which could lead to some funny business later.

Fixes: 9332f3b1b99a ("drm/i915: Combine loops within i915_gem_evict_something")
Cc: Chris Wilson <chris@chris-wilson.co.uk>
Signed-off-by: Matthew Auld <matthew.auld@intel.com>
---
 drivers/gpu/drm/i915/i915_gem_evict.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Chris Wilson Jan. 5, 2017, 3:13 p.m. UTC | #1
On Thu, Jan 05, 2017 at 02:41:31PM +0000, Matthew Auld wrote:
> If we find a suitable victim node on our first pass, then ret
> will be uninitialized which could lead to some funny business later.
> 
> Fixes: 9332f3b1b99a ("drm/i915: Combine loops within i915_gem_evict_something")
> Cc: Chris Wilson <chris@chris-wilson.co.uk>
> Signed-off-by: Matthew Auld <matthew.auld@intel.com>
> ---
>  drivers/gpu/drm/i915/i915_gem_evict.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/gpu/drm/i915/i915_gem_evict.c b/drivers/gpu/drm/i915/i915_gem_evict.c
> index 50129ec1caab..19716548c455 100644
> --- a/drivers/gpu/drm/i915/i915_gem_evict.c
> +++ b/drivers/gpu/drm/i915/i915_gem_evict.c
> @@ -109,7 +109,7 @@ i915_gem_evict_something(struct i915_address_space *vm,
>  	}, **phase;
>  	struct i915_vma *vma, *next;
>  	struct drm_mm_node *node;
> -	int ret;
> +	int ret = 0;

Please don't randomly initialise locals. It is meant to be initialised
just prior to the unbind loop. It appears that my patches are
out-of-order. :|
-Chris
Matthew Auld Jan. 5, 2017, 3:26 p.m. UTC | #2
On 5 January 2017 at 15:13, Chris Wilson <chris@chris-wilson.co.uk> wrote:
> On Thu, Jan 05, 2017 at 02:41:31PM +0000, Matthew Auld wrote:
>> If we find a suitable victim node on our first pass, then ret
>> will be uninitialized which could lead to some funny business later.
>>
>> Fixes: 9332f3b1b99a ("drm/i915: Combine loops within i915_gem_evict_something")
>> Cc: Chris Wilson <chris@chris-wilson.co.uk>
>> Signed-off-by: Matthew Auld <matthew.auld@intel.com>
>> ---
>>  drivers/gpu/drm/i915/i915_gem_evict.c | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/drivers/gpu/drm/i915/i915_gem_evict.c b/drivers/gpu/drm/i915/i915_gem_evict.c
>> index 50129ec1caab..19716548c455 100644
>> --- a/drivers/gpu/drm/i915/i915_gem_evict.c
>> +++ b/drivers/gpu/drm/i915/i915_gem_evict.c
>> @@ -109,7 +109,7 @@ i915_gem_evict_something(struct i915_address_space *vm,
>>       }, **phase;
>>       struct i915_vma *vma, *next;
>>       struct drm_mm_node *node;
>> -     int ret;
>> +     int ret = 0;
>
> Please don't randomly initialise locals. It is meant to be initialised
> just prior to the unbind loop. It appears that my patches are
> out-of-order. :|
Oh, then I misread the intention of the code, sorry.
diff mbox

Patch

diff --git a/drivers/gpu/drm/i915/i915_gem_evict.c b/drivers/gpu/drm/i915/i915_gem_evict.c
index 50129ec1caab..19716548c455 100644
--- a/drivers/gpu/drm/i915/i915_gem_evict.c
+++ b/drivers/gpu/drm/i915/i915_gem_evict.c
@@ -109,7 +109,7 @@  i915_gem_evict_something(struct i915_address_space *vm,
 	}, **phase;
 	struct i915_vma *vma, *next;
 	struct drm_mm_node *node;
-	int ret;
+	int ret = 0;
 
 	lockdep_assert_held(&vm->i915->drm.struct_mutex);
 	trace_i915_gem_evict(vm, min_size, alignment, flags);