Received: by 2002:a25:c205:0:0:0:0:0 with SMTP id s5csp3159197ybf; Tue, 3 Mar 2020 00:22:52 -0800 (PST) X-Google-Smtp-Source: ADFU+vu3Ia/02tTNHiaJ340Jce+6Fy/b5JIOuqltiuPKENQhlyza2LJ2XGuAMTsD84hB2vDNeSem X-Received: by 2002:a9d:6ad6:: with SMTP id m22mr2659322otq.7.1583223772774; Tue, 03 Mar 2020 00:22:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1583223772; cv=none; d=google.com; s=arc-20160816; b=Z0HzzhIMPfmJEOfsrdQRWxv119kLPDYE8SAIja8/BPWaYU+wfe30LZN75bQiouF8Vu GewqPvBnBHECTZnEskFB15C+0A1XoSl3jMbDruTNAZRqugqSi1GB8ezVbTBs5dT2Y+oB V6AN6+uaJaUJkeocIKCWkPh89n7iN6PuI0BUtfC0p8VlAmuEPxgebdj+WNDX1z4ciKy0 rw2f48Odf87yA35sB5q87+Jnl8a4I9dwjmHlRdDgzyG/DAQpZRzC8WD+A3j9bQrhLMRV vtkSC8yGpu6COrX2+SqIAxAajNt9UVCVNma4ujB+PgkBRVP/Tq9tYLKgLsAsCG+CM5EA khtA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=GUKiYpi9FYS09yZZU0VyVoSg4aODr62keM14BQquORs=; b=X5SZatRxCC+QrrXzgJcvW5kh0ok276Wn87KmOt8gC1fXFetnBBGOATJnHBlCt90lsA AQpkhU0X/ZnZZcoUK304fTMIHgkXOa3Y9waN7tNo+hKmq6CP75Y2QHZ9OE0uTgFcYU64 CZcJNw/D/spgTT4k8lDmG5Cv3+lABUu0oPKSGKqXwOMMxt68Z+J9U5l6g9soBjWfYMvQ Mr8jw24pfg87zCG7JCUPgG0Zp771C5nQB4obX6GtFlU6eN0phPZvpKmNA8cL3dxEA42/ 7ysCwidqy/3VYbWGZhoaxYzcofaySYMoCUHWLIW1GbzbU9b3j0kcmE7R3AVm78kxG2E+ 7w6Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ffwll.ch header.s=google header.b=iTWHWXN1; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j15si7581094oii.163.2020.03.03.00.22.40; Tue, 03 Mar 2020 00:22:52 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@ffwll.ch header.s=google header.b=iTWHWXN1; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727636AbgCCIVk (ORCPT + 99 others); Tue, 3 Mar 2020 03:21:40 -0500 Received: from mail-ot1-f68.google.com ([209.85.210.68]:33296 "EHLO mail-ot1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727552AbgCCIVk (ORCPT ); Tue, 3 Mar 2020 03:21:40 -0500 Received: by mail-ot1-f68.google.com with SMTP id a20so2188742otl.0 for ; Tue, 03 Mar 2020 00:21:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ffwll.ch; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=GUKiYpi9FYS09yZZU0VyVoSg4aODr62keM14BQquORs=; b=iTWHWXN1cBYaPALi8BmMvDHdDzP0pKeUtHzIMaZWEkPiFOOdEMBDcTNEIqY961Mb8h LbLyoMlq1lKaFpSLXNK3VlkxsJ5KXgQhZaXfV5s4O24srTrobcEMWdltxWq0MqlNjLW1 IgAJ+fkveUQq17XOSt7mVFTzXwRn4y6SiVqHI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=GUKiYpi9FYS09yZZU0VyVoSg4aODr62keM14BQquORs=; b=aa6wxUUU7YfGYgvI89LpbmsxSbAe3KRJuYD3KhX6lPj9G8TIHvfacvxLpDOh46hNvu Q9JUl3zVxV6Us1x9d/ekHSDqzPzX15IbgjhDrqMbZdoWcXZaJPwDA/Uv927LA9cT3tOX XO/yF7GRTpxbldiMAvwqyT94BTvdQYGoBrtdRn8GV9dHMOsgJCmqQYJYFJvmmKwKiQ0a 3ke0EbkajnRnEELXCtbTx85RxJWaG8jFn77QC+eHVokUMuTnbkxrzVZBFzVYCBDAl3Lf FutjLQDot9CUTrcZ2+1Tm/L8hvt9+2J/EyxPW21Hq2vP47IEBTmi8EPiU4NeGzloVY1w dxRg== X-Gm-Message-State: ANhLgQ345iPQwnKb687Mbn0aG6iserKUJ0+TWC0HKtUQIquZ/mcAL28D eNw4fc3Gcita1XeieQTJBqPAE5YJpiKMndjqI3Q2tg== X-Received: by 2002:a9d:6256:: with SMTP id i22mr676037otk.106.1583223698573; Tue, 03 Mar 2020 00:21:38 -0800 (PST) MIME-Version: 1.0 References: <20200220062229.68762-1-keescook@chromium.org> <202003022038.07A611E@keescook> In-Reply-To: <202003022038.07A611E@keescook> From: Daniel Vetter Date: Tue, 3 Mar 2020 09:21:26 +0100 Message-ID: Subject: Re: [PATCH] drm/edid: Distribute switch variables for initialization To: Kees Cook Cc: Maarten Lankhorst , Maxime Ripard , David Airlie , dri-devel , Alexander Potapenko , Linux Kernel Mailing List Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Mar 3, 2020 at 5:39 AM Kees Cook wrote: > > On Wed, Feb 19, 2020 at 10:22:29PM -0800, Kees Cook wrote: > > Variables declared in a switch statement before any case statements > > cannot be automatically initialized with compiler instrumentation (as > > they are not part of any execution flow). With GCC's proposed automatic > > stack variable initialization feature, this triggers a warning (and the= y > > don't get initialized). Clang's automatic stack variable initialization > > (via CONFIG_INIT_STACK_ALL=3Dy) doesn't throw a warning, but it also > > doesn't initialize such variables[1]. Note that these warnings (or sile= nt > > skipping) happen before the dead-store elimination optimization phase, > > so even when the automatic initializations are later elided in favor of > > direct initializations, the warnings remain. > > > > To avoid these problems, move such variables into the "case" where > > they're used or lift them up into the main function body. > > > > drivers/gpu/drm/drm_edid.c: In function =E2=80=98drm_edid_to_eld=E2=80= =99: > > drivers/gpu/drm/drm_edid.c:4395:9: warning: statement will never be exe= cuted [-Wswitch-unreachable] > > 4395 | int sad_count; > > | ^~~~~~~~~ > > > > [1] https://bugs.llvm.org/show_bug.cgi?id=3D44916 > > > > Signed-off-by: Kees Cook > > Ping. Can someone pick this up, please? Whatever the reasons, but your original patch didn't make it through to dri-devel. Can you pls resubmit? Thanks, Daniel > > Thanks! > > -Kees > > > --- > > drivers/gpu/drm/drm_edid.c | 5 +++-- > > 1 file changed, 3 insertions(+), 2 deletions(-) > > > > diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c > > index 805fb004c8eb..2941b65b427f 100644 > > --- a/drivers/gpu/drm/drm_edid.c > > +++ b/drivers/gpu/drm/drm_edid.c > > @@ -4392,9 +4392,9 @@ static void drm_edid_to_eld(struct drm_connector = *connector, struct edid *edid) > > dbl =3D cea_db_payload_len(db); > > > > switch (cea_db_tag(db)) { > > - int sad_count; > > + case AUDIO_BLOCK: { > > > > - case AUDIO_BLOCK: > > + int sad_count; > > /* Audio Data Block, contains SADs */ > > sad_count =3D min(dbl / 3, 15 - total_sad= _count); > > if (sad_count >=3D 1) > > @@ -4402,6 +4402,7 @@ static void drm_edid_to_eld(struct drm_connector = *connector, struct edid *edid) > > &db[1], sad_count * 3); > > total_sad_count +=3D sad_count; > > break; > > + } > > case SPEAKER_BLOCK: > > /* Speaker Allocation Data Block */ > > if (dbl >=3D 1) > > > > -- > Kees Cook --=20 Daniel Vetter Software Engineer, Intel Corporation +41 (0) 79 365 57 48 - http://blog.ffwll.ch