[PATCH] drm/i915/selftests: Fix resource leak in __sseu_prepare

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Fix the resource leak reported by static code checker.

Cc: Tvrtko Ursulin <tvrtko.ursulin@xxxxxxxxx>
Signed-off-by: Radhakrishna Sripada <radhakrishna.sripada@xxxxxxxxx>
---
 drivers/gpu/drm/i915/selftests/i915_gem_context.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/drivers/gpu/drm/i915/selftests/i915_gem_context.c b/drivers/gpu/drm/i915/selftests/i915_gem_context.c
index d00d0bb07784..0d821a679f74 100644
--- a/drivers/gpu/drm/i915/selftests/i915_gem_context.c
+++ b/drivers/gpu/drm/i915/selftests/i915_gem_context.c
@@ -726,14 +726,13 @@ __sseu_prepare(struct drm_i915_private *i915,
 
 		ret = igt_spinner_init(spin, i915);
 		if (ret)
-			return ret;
+			goto clean;
 
 		rq = igt_spinner_create_request(spin, ctx, engine, MI_NOOP);
 		if (IS_ERR(rq)) {
 			ret = PTR_ERR(rq);
 			igt_spinner_fini(spin);
-			kfree(spin);
-			goto out;
+			goto clean;
 		}
 
 		i915_request_add(rq);
@@ -742,14 +741,16 @@ __sseu_prepare(struct drm_i915_private *i915,
 			pr_err("%s: Spinner failed to start!\n", name);
 			igt_spinner_end(spin);
 			igt_spinner_fini(spin);
-			kfree(spin);
 			ret = -ETIMEDOUT;
-			goto out;
+			goto clean;
 		}
 
 		*spin_out = spin;
+		goto out;
 	}
 
+clean:
+	kfree(spin);
 out:
 	return ret;
 }
-- 
2.20.0.rc2.7.g965798d1f299

_______________________________________________
Intel-gfx mailing list
Intel-gfx@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/intel-gfx




[Index of Archives]     [AMD Graphics]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux