drm/i915: fix handling gen8_emit_flush_coherentl3_wa result
authorAndrzej Hajda <a.hajda@samsung.com>
Mon, 21 Sep 2015 13:33:35 +0000 (15:33 +0200)
committerDaniel Vetter <daniel.vetter@ffwll.ch>
Tue, 22 Sep 2015 15:10:52 +0000 (17:10 +0200)
The function can return negative value.

The problem has been detected using proposed semantic patch
scripts/coccinelle/tests/unsigned_lesser_than_zero.cocci [1].

[1]: http://permalink.gmane.org/gmane.linux.kernel/2038576

Signed-off-by: Andrzej Hajda <a.hajda@samsung.com>
Reviewed-by: Jani Nikula <jani.nikula@intel.com>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
drivers/gpu/drm/i915/intel_lrc.c

index fe06accb0797f01c1ac689a48aa573dc13eb1540..ff9a481ed997bc45cb85a0b6f7dbf03f9282ad86 100644 (file)
@@ -1254,9 +1254,10 @@ static int gen8_init_indirectctx_bb(struct intel_engine_cs *ring,
 
        /* WaFlushCoherentL3CacheLinesAtContextSwitch:bdw */
        if (IS_BROADWELL(ring->dev)) {
-               index = gen8_emit_flush_coherentl3_wa(ring, batch, index);
-               if (index < 0)
-                       return index;
+               int rc = gen8_emit_flush_coherentl3_wa(ring, batch, index);
+               if (rc < 0)
+                       return rc;
+               index = rc;
        }
 
        /* WaClearSlmSpaceAtContextSwitch:bdw,chv */