Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

i915: don't call drm_atomic_state_put on invalid pointer

The introduction of reference counting on the state structures caused
sanitize_watermarks() in i915 to break in the error handling case,
as pointed out by gcc -Wmaybe-uninitialized

drivers/gpu/drm/i915/intel_display.c: In function ‘intel_modeset_init’:
include/drm/drm_atomic.h:224:2: error: ‘state’ may be used uninitialized in this function [-Werror=maybe-uninitialized]

This changes the function back to only drop the reference count
when it was successfully allocated first.

Fixes: 0853695c3ba4 ("drm: Add reference counting to drm_atomic_state")
Cc: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Reviewed-by: Eric Engestrom <eric.engestrom@imgtec.com>
Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Link: http://patchwork.freedesktop.org/patch/msgid/20161018151652.2690201-1-arnd@arndb.de

authored by

Arnd Bergmann and committed by
Daniel Vetter
b9a1b717 488546fc

+3 -2
+3 -2
drivers/gpu/drm/i915/intel_display.c
··· 16294 16294 * BIOS-programmed watermarks untouched and hope for the best. 16295 16295 */ 16296 16296 WARN(true, "Could not determine valid watermarks for inherited state\n"); 16297 - goto fail; 16297 + goto put_state; 16298 16298 } 16299 16299 16300 16300 /* Write calculated watermark values back */ ··· 16305 16305 dev_priv->display.optimize_watermarks(cs); 16306 16306 } 16307 16307 16308 - fail: 16308 + put_state: 16309 16309 drm_atomic_state_put(state); 16310 + fail: 16310 16311 drm_modeset_drop_locks(&ctx); 16311 16312 drm_modeset_acquire_fini(&ctx); 16312 16313 }