From patchwork Wed Jan 13 20:26:55 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 101177 Delivered-To: patch@linaro.org Received: by 10.112.130.2 with SMTP id oa2csp3588148lbb; Wed, 13 Jan 2016 12:27:04 -0800 (PST) X-Received: by 10.98.13.197 with SMTP id 66mr207811pfn.125.1452716824615; Wed, 13 Jan 2016 12:27:04 -0800 (PST) Return-Path: Received: from gabe.freedesktop.org (gabe.freedesktop.org. [131.252.210.177]) by mx.google.com with ESMTP id uk9si3997122pac.166.2016.01.13.12.27.04; Wed, 13 Jan 2016 12:27:04 -0800 (PST) Received-SPF: pass (google.com: domain of dri-devel-bounces@lists.freedesktop.org designates 131.252.210.177 as permitted sender) client-ip=131.252.210.177; Authentication-Results: mx.google.com; spf=pass (google.com: domain of dri-devel-bounces@lists.freedesktop.org designates 131.252.210.177 as permitted sender) smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 9421A6E714; Wed, 13 Jan 2016 12:27:03 -0800 (PST) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mout.kundenserver.de (mout.kundenserver.de [212.227.126.130]) by gabe.freedesktop.org (Postfix) with ESMTPS id 2B56F6E714 for ; Wed, 13 Jan 2016 12:27:01 -0800 (PST) Received: from wuerfel.localnet ([134.3.118.24]) by mrelayeu.kundenserver.de (mreue001) with ESMTPSA (Nemesis) id 0Lbm9E-1Zrmlj01RM-00jI6T; Wed, 13 Jan 2016 21:26:59 +0100 From: Arnd Bergmann To: David Airlie Subject: [PATCH] drm: avoid uninitialized timestamp use in wait_vblank Date: Wed, 13 Jan 2016 21:26:55 +0100 Message-ID: <4063054.9IPA0UdbYa@wuerfel> User-Agent: KMail/4.11.5 (Linux/3.16.0-10-generic; KDE/4.11.5; x86_64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1vdx37 Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, dri-devel@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" gcc warns about the timestamp in drm_wait_vblank being possibly used without an initialization: drivers/gpu/drm/drm_irq.c: In function 'drm_wait_vblank': drivers/gpu/drm/drm_irq.c:1755:28: warning: 'now.tv_usec' may be used uninitialized in this function [-Wmaybe-uninitialized] vblwait->reply.tval_usec = now.tv_usec; drivers/gpu/drm/drm_irq.c:1754:27: warning: 'now.tv_sec' may be used uninitialized in this function [-Wmaybe-uninitialized] vblwait->reply.tval_sec = now.tv_sec; This can happen if drm_vblank_count_and_time() returns 0 in its error path. To sanitize the error case, I'm changing that function to return a zero timestamp when it fails. Signed-off-by: Arnd Bergmann Fixes: e6ae8687a87b ("drm: idiot-proof vblank") --- I'm going through the maybe-unused warnings in randconfig builds, this one is apparently not a false positive, although it only happens if something else has already gone wrong. diff --git a/drivers/gpu/drm/drm_irq.c b/drivers/gpu/drm/drm_irq.c index d12a4efa651b..d32ff169fdb8 100644 --- a/drivers/gpu/drm/drm_irq.c +++ b/drivers/gpu/drm/drm_irq.c @@ -939,8 +939,10 @@ u32 drm_vblank_count_and_time(struct drm_device *dev, unsigned int pipe, int count = DRM_TIMESTAMP_MAXRETRIES; u32 cur_vblank; - if (WARN_ON(pipe >= dev->num_crtcs)) + if (WARN_ON(pipe >= dev->num_crtcs)) { + *vblanktime = (struct timeval) { 0 }; return 0; + } /* * Vblank timestamps are read lockless. To ensure consistency the vblank