Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758789AbcJRHqP (ORCPT ); Tue, 18 Oct 2016 03:46:15 -0400 Received: from mail-lf0-f65.google.com ([209.85.215.65]:36132 "EHLO mail-lf0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752020AbcJRHqH (ORCPT ); Tue, 18 Oct 2016 03:46:07 -0400 Date: Tue, 18 Oct 2016 09:46:02 +0200 From: Daniel Vetter To: Mario Kleiner Cc: Arnd Bergmann , David Airlie , Linus Torvalds , linux-kernel@vger.kernel.org, Rob Clark , Daniel Vetter , Dave Airlie , Ville =?iso-8859-1?Q?Syrj=E4l=E4?= , Alex Deucher , Gustavo Padovan , Matthew Auld , dri-devel@lists.freedesktop.org Subject: Re: [PATCH 18/28] drm: avoid uninitialized timestamp use in wait_vblank Message-ID: <20161018074602.GY20761@phenom.ffwll.local> Mail-Followup-To: Mario Kleiner , Arnd Bergmann , David Airlie , Linus Torvalds , linux-kernel@vger.kernel.org, Rob Clark , Dave Airlie , Ville =?iso-8859-1?Q?Syrj=E4l=E4?= , Alex Deucher , Gustavo Padovan , Matthew Auld , dri-devel@lists.freedesktop.org References: <20161017220342.1627073-1-arnd@arndb.de> <20161017221355.1861551-6-arnd@arndb.de> <374ecb85-dfff-ecc4-99ee-dba5ccbc169f@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <374ecb85-dfff-ecc4-99ee-dba5ccbc169f@gmail.com> X-Operating-System: Linux phenom 4.6.0-1-amd64 User-Agent: Mutt/1.6.0 (2016-04-01) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2062 Lines: 56 On Tue, Oct 18, 2016 at 01:47:24AM +0200, Mario Kleiner wrote: > On 10/18/2016 12:13 AM, Arnd Bergmann wrote: > > 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. Hm, sorry I missed that. > > 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); > > > > Looks good to me. > > Reviewed-by: Mario Kleiner Applied to drm-misc, thanks. -Daniel -- Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch