Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758813AbcJQWQV (ORCPT ); Mon, 17 Oct 2016 18:16:21 -0400 Received: from mout.kundenserver.de ([212.227.126.187]:63137 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1758713AbcJQWQG (ORCPT ); Mon, 17 Oct 2016 18:16:06 -0400 From: Arnd Bergmann To: David Airlie Cc: Linus Torvalds , linux-kernel@vger.kernel.org, Arnd Bergmann , Rob Clark , Daniel Vetter , Mario Kleiner , Dave Airlie , =?UTF-8?q?Ville=20Syrj=C3=A4l=C3=A4?= , Alex Deucher , Gustavo Padovan , Matthew Auld , dri-devel@lists.freedesktop.org Subject: [PATCH 18/28] drm: avoid uninitialized timestamp use in wait_vblank Date: Tue, 18 Oct 2016 00:13:39 +0200 Message-Id: <20161017221355.1861551-6-arnd@arndb.de> X-Mailer: git-send-email 2.9.0 In-Reply-To: <20161017220342.1627073-1-arnd@arndb.de> References: <20161017220342.1627073-1-arnd@arndb.de> X-Provags-ID: V03:K0:BDOatE2PMcfnfn2dMXFhgP453G8O4+zqCixDWvicHfyCe7hYSa/ B38bMms280WWp8DrttdtWChM3fT09wWGKFIzofAnnEYVW1lnsJNqfCc+CWS/5D3rhlb2w2J bb5JDz2+t8cNVMCGPNagIN+axAIYqbunk7cKNERsYoHD6kvZIXEX515FRIH6dYVHNHgD8Kv dqoGWaw6JcJfzTwztXYBg== X-UI-Out-Filterresults: notjunk:1;V01:K0:Zqbn8kIuckU=:Ur9LfWQaRTwPSvmZoi34ov qvOL+mVuGvJVaB3yjJ3W2r0yQQPEamNZemd6mnX5DfjSNkrmwYrklfzHhY/pnLF/8jOnj24YL Ah3YnagDsBuxHRxKR/U9V5xoY+CvjQtsqxlWchRDqbp0qolgsLvRJcvpBK5y+J4Li4PKyfST6 JJUaUL8znLFikLO62Dg6a6LKuCwHdSL+QaIYOTvf07EElosX4TGgoFjLb9IRDVCP+qwr4h5za xTygRfUxfqa0mIi96TuvTrgi6IN57W1jsuPuL8zeTnLdkaCHM4zQlFhPuBnHjNudYSFNZ65tU Yzi5jVZIx7t69G0gUBuvXoqd02phffATjUgoLazISYPMnRbyX/CBGtKOKn+FmprsMmpkciMGP XHH0qE4S1wzZaGKt3IoFerMWJ0Iqw08CBLNLhJ5Pa1f5t5bRvqnVmBP+v2JQ0Br2JYmD7lwul gwGETZ0EdFnYCDPJej2CZ3MoNpy53xP+UdQs9SNU6p6DjNDfQ0xmtttPgRvhmcvKy+4rMXMLr c7dSof7o5O5kC7oQ2bE6VaEW3wR5iVu4coI/wRf4jMEsyZDcIjzdBbHzdHFEIMMEVMhqV1ESW dbkWZrIS8pMVkjafPfmAWbOcqViscIrAkMLLDPmzQGktXNEvsnvWSm44S8wHOyI8v98DJLNx+ Bsp6sU39l/8NMcEP8qT1UvWeP8sgjgROMjElhnSNx1XgEBi+HZpfmCvZf2qCHHE9yMqM= Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1579 Lines: 42 gcc warns about the timestamp in drm_wait_vblank being possibly used without an initialization: drivers/gpu/drm/drm_irq.c: In function 'drm_crtc_send_vblank_event': drivers/gpu/drm/drm_irq.c:992:24: error: 'now.tv_usec' may be used uninitialized in this function [-Werror=maybe-uninitialized] drivers/gpu/drm/drm_irq.c:1069:17: note: 'now.tv_usec' was declared here drivers/gpu/drm/drm_irq.c:991:23: error: 'now.tv_sec' may be used uninitialized in this function [-Werror=maybe-uninitialized] 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. Fixes: e6ae8687a87b ("drm: idiot-proof vblank") Reviewed-by: David Herrmann Cc: Rob Clark Cc: Daniel Vetter Signed-off-by: Arnd Bergmann --- First submitted in January 2016, second submission in February, the patch is still required. drivers/gpu/drm/drm_irq.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/drm_irq.c b/drivers/gpu/drm/drm_irq.c index b969a64..48a6167 100644 --- a/drivers/gpu/drm/drm_irq.c +++ b/drivers/gpu/drm/drm_irq.c @@ -952,8 +952,10 @@ static u32 drm_vblank_count_and_time(struct drm_device *dev, unsigned int pipe, u32 vblank_count; unsigned int seq; - if (WARN_ON(pipe >= dev->num_crtcs)) + if (WARN_ON(pipe >= dev->num_crtcs)) { + *vblanktime = (struct timeval) { 0 }; return 0; + } do { seq = read_seqbegin(&vblank->seqlock); -- 2.9.0