From patchwork Tue Oct 18 15:16:23 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 9382339 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id E0B3B60839 for ; Tue, 18 Oct 2016 15:17:20 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D142729656 for ; Tue, 18 Oct 2016 15:17:20 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C5F9A2965A; Tue, 18 Oct 2016 15:17:20 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.7 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RCVD_IN_SORBS_SPAM autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 3E6EF29656 for ; Tue, 18 Oct 2016 15:17:20 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 8232E6E04A; Tue, 18 Oct 2016 15:17:17 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mout.kundenserver.de (mout.kundenserver.de [217.72.192.75]) by gabe.freedesktop.org (Postfix) with ESMTPS id 0CD1E6E752 for ; Tue, 18 Oct 2016 15:17:14 +0000 (UTC) Received: from wuerfel.lan. ([78.43.20.153]) by mrelayeu.kundenserver.de (mreue104) with ESMTPA (Nemesis) id 0MGyyA-1c97Jj30Da-00DsIH; Tue, 18 Oct 2016 17:16:57 +0200 From: Arnd Bergmann To: Daniel Vetter , Jani Nikula , David Airlie Subject: [PATCH] i915: don't call drm_atomic_state_put on invalid pointer Date: Tue, 18 Oct 2016 17:16:23 +0200 Message-Id: <20161018151652.2690201-1-arnd@arndb.de> X-Mailer: git-send-email 2.9.0 MIME-Version: 1.0 X-Provags-ID: V03:K0:Ce4zls/6v//Ze59xbaiMBrkxiq8TBQIPF/dTU13yv937oQYoHI8 YMeEhGkW1qMoIXq3iHJ+lSQ0IBB2xGi4erKb1tl2yy6TmiOFF1BqRWsG9CcF/kNnT3i1fAV 2Jlx9+wAXb2aoY3CfiMhQoa4KJpMuY4u+VktcE+2X2YmA8xwM6ZUCskeVIrB8XG1w+zeaFz wsZLjX3RvF+QM10kljk3w== X-UI-Out-Filterresults: notjunk:1; V01:K0:63w1v3I8uWs=:G4fZdOmhLUa0ua+Weox6Bj 5ApmnwjKlPUm7I9by+DLHKlgRnyGlDKpt0Kd57s530iUba5qNuE9q9owdt+S/wCOClO6HZZ08 D48sfGTap5oxurIooATbYiIagNYOfD03Bgm5IApy4xKThsQShmEFMcLHTw9nuunRqYhgQwnbz AtoSySMjbOhkZNuhQwsfebidQa/eqbt0ioQw09d9UNKISX1u9Evlow2YWqRl6pqAtp7s9ybtX L157imStrFM1L3Cu1bpqj1YztxmDbFVg6wc5DpduYwYBVkOTuv92l8LirP+9rbu78gzsYF0MM wvNZ1KdqwR2WFvf5yBek/mX0RBg+MTI33oNS3YBFvDR3hJb6RfnEQbfs8lBgAZc3pwU+bMJXt 55/MYkRFPZILjujxuO++S8WrXGTgVEj+50nmUasDwv/S2Le0E+HrAaV16Td9kr3FXuVd0dHvB G+0jgiiZB7P/rwMmvzJ9dpnex0rWCl7nh1uiQysmg0P5T6IxFBNr+g+dkO3Mf3SAnbs5jfrGk a8fPXxexXbU+MIWdys59/6xwL9MRgRGu4oz6qFi5+dXzCAZXuvdA+kSz/SSVCj13/YY7YCVAE lbqHK3FC4thDu0i7FFeXI9jmcD6SWIVsnniH5EFPAdC8DiL5anI5kEvL5CaHsxYkC47MIz/fN j3Hyjie8WQHVoKXhNKP7WDOi5EGT+q7YuZMfPwIkDVgPagJNdTtAdHEkgfns6MskQ+D/7usF8 aLHB44paozz/NHi1 Cc: Ander Conselvan de Oliveira , Arnd Bergmann , Daniel Vetter , linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, intel-gfx@lists.freedesktop.org X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP 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 Cc: Daniel Vetter Signed-off-by: Arnd Bergmann Reviewed-by: Eric Engestrom Reviewed-by: Chris Wilson --- drivers/gpu/drm/i915/intel_display.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c index 6d168685bbda..6a26da143aa6 100644 --- a/drivers/gpu/drm/i915/intel_display.c +++ b/drivers/gpu/drm/i915/intel_display.c @@ -16314,7 +16314,7 @@ static void sanitize_watermarks(struct drm_device *dev) * BIOS-programmed watermarks untouched and hope for the best. */ WARN(true, "Could not determine valid watermarks for inherited state\n"); - goto fail; + goto put_state; } /* Write calculated watermark values back */ @@ -16325,8 +16325,9 @@ static void sanitize_watermarks(struct drm_device *dev) dev_priv->display.optimize_watermarks(cs); } -fail: +put_state: drm_atomic_state_put(state); +fail: drm_modeset_drop_locks(&ctx); drm_modeset_acquire_fini(&ctx); }