diff mbox series

[next] drm/i915: Fix an uninitialized variable issue

Message ID 20210401125505.2012496-1-colin.king@canonical.com (mailing list archive)
State New, archived
Headers show
Series [next] drm/i915: Fix an uninitialized variable issue | expand

Commit Message

Colin King April 1, 2021, 12:55 p.m. UTC
From: Colin Ian King <colin.king@canonical.com>

Currently there is a while loop that contains a handful of continue
statements that can skip over the assignment of the variable err. At
the end of the loop there is a potiential for err to be unassigned
and possibly causing issues when err is checked for a non-zero value.
Fix this by setting err to zero before the while loop starts.

Addresses-Coverity: ("Uninitialized scalar variable")
Fixes: cf41a8f1dc1e ("drm/i915: Finally remove obj->mm.lock.")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
 drivers/gpu/drm/i915/gem/i915_gem_shrinker.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff mbox series


diff --git a/drivers/gpu/drm/i915/gem/i915_gem_shrinker.c b/drivers/gpu/drm/i915/gem/i915_gem_shrinker.c
index 3e248d3bd869..1e24ba872029 100644
--- a/drivers/gpu/drm/i915/gem/i915_gem_shrinker.c
+++ b/drivers/gpu/drm/i915/gem/i915_gem_shrinker.c
@@ -180,6 +180,7 @@  i915_gem_shrink(struct i915_gem_ww_ctx *ww,
 		 * the unbound/bound list until actually freed.
 		spin_lock_irqsave(&i915->mm.obj_lock, flags);
+		err = 0;
 		while (count < target &&
 		       (obj = list_first_entry_or_null(phase->list,
@@ -202,7 +203,6 @@  i915_gem_shrink(struct i915_gem_ww_ctx *ww,
 			spin_unlock_irqrestore(&i915->mm.obj_lock, flags);
-			err = 0;
 			if (unsafe_drop_pages(obj, shrink)) {
 				/* May arrive from get_pages on another bo */
 				if (!ww) {