drm/i915: Satisfy smatch that a loop has at least one iteration
diff mbox series

Message ID 20200117110603.2982286-1-chris@chris-wilson.co.uk
State New
Headers show
Series
  • drm/i915: Satisfy smatch that a loop has at least one iteration
Related show

Commit Message

Chris Wilson Jan. 17, 2020, 11:06 a.m. UTC
Smatch worries that the engine->mask may be 0 leading to the loop being
shortcircuited leaving the next pointer unset,

drivers/gpu/drm/i915/i915_active.c:667 i915_active_acquire_preallocate_barrier() error: uninitialized symbol 'next'.

Assert that mask is not 0 and smatch can then verify that next must be
initialised before use.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
---
 drivers/gpu/drm/i915/i915_active.c | 1 +
 1 file changed, 1 insertion(+)

Comments

Matthew Auld Jan. 17, 2020, 1:21 p.m. UTC | #1
On Fri, 17 Jan 2020 at 11:06, Chris Wilson <chris@chris-wilson.co.uk> wrote:
>
> Smatch worries that the engine->mask may be 0 leading to the loop being
> shortcircuited leaving the next pointer unset,
>
> drivers/gpu/drm/i915/i915_active.c:667 i915_active_acquire_preallocate_barrier() error: uninitialized symbol 'next'.
>
> Assert that mask is not 0 and smatch can then verify that next must be
> initialised before use.
>
> Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
> Cc: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
Reviewed-by: Matthew Auld <matthew.auld@intel.com>

Patch
diff mbox series

diff --git a/drivers/gpu/drm/i915/i915_active.c b/drivers/gpu/drm/i915/i915_active.c
index f3da5c06f331..ace55d5d4ca7 100644
--- a/drivers/gpu/drm/i915/i915_active.c
+++ b/drivers/gpu/drm/i915/i915_active.c
@@ -621,6 +621,7 @@  int i915_active_acquire_preallocate_barrier(struct i915_active *ref,
 	 * We can then use the preallocated nodes in
 	 * i915_active_acquire_barrier()
 	 */
+	GEM_BUG_ON(!mask);
 	for_each_engine_masked(engine, gt, mask, tmp) {
 		u64 idx = engine->kernel_context->timeline->fence_context;
 		struct active_node *node;