From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S935056AbdCWPRD (ORCPT ); Thu, 23 Mar 2017 11:17:03 -0400 Received: from mout.kundenserver.de ([212.227.126.134]:54979 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933890AbdCWPRB (ORCPT ); Thu, 23 Mar 2017 11:17:01 -0400 From: Arnd Bergmann To: Jaroslav Kysela , Takashi Iwai Cc: Arnd Bergmann , Colin Ian King , alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org Subject: [PATCH] ALSA: au88x0: avoid theoretical uninitialized access Date: Thu, 23 Mar 2017 16:15:55 +0100 Message-Id: <20170323151607.636485-1-arnd@arndb.de> X-Mailer: git-send-email 2.9.0 X-Provags-ID: V03:K0:CfHL7hq88FmzMgW63fmj/9pz/SULvGqz8QS9AXtIzeC5a6OV3kc SmtxEfzAtVetKI1jBvfmyaJFY/m9lGl9P79kVj3RDt9l0P8yJtzbdMI5Rz1CrB0Xyx7ndEw ipl3wtqE5/mVswMUn5TUHao4lvySbmPU0i99w9XgBQAFn9oUFipm05EyOlXhhttPegNIe5S SBnF0lYtAKusGatKlzsew== X-UI-Out-Filterresults: notjunk:1;V01:K0:zfVyA6DYVBk=:xi+G9sLdYv2UtGxGVHqp4S /EGoKgwcUPA8bkidWoMEkgKBEftzZFowoiojlrcc1C1J3tIFiJTCHgehACeu0eJfjH+qRTP/B K0TDn+/pn8jxnlRZH+Tjhi0xVWLevF7kBzetkdX9e1r9dzXL7RMShud5hYj0TnaBskS1G3hCg 9BI2ipVKHxRL6CButIQbbcQcF4gZoxODAnPG5deHRtg5Xknl1RrE8AhQyIdxphe0Fp+5Tl+bC 4Eg8mSlenAU6NrzQm3jl2//koCcIc0krm3QzRleeGi5gU8GEgS+1Sl4I5nHEHdBOPU4H2rQUj v6dzGwyTYb3kgrE8Vpxy/sFZXl+YBh7inNCLkXZb+ViuEIxB1H7eNwH6PIjC4kL/NTYxEN1HH XZAup/ynXRro6OUKBakhyc8hngVWyfwXabYcAd4KPuF2HX0T+bWxiE2yRLgFm7xMbmb+1Gpnf IIyCKsfUBJWdVy8ogtF6mPVuN6wJOVWCsx/b8/BkOGZ/UnJ/t2pcmksu/kUAl6Jpc/ItyjO/H cFaxKmHtNwgPh9qZQ90VElzwFfE3nmddGxrTDI4MxEd4uCM2t7fhvzHrwXT2fhpv59A0aj6Oc ACFi+heI7qi61Dw8YuZKBWmp4h1JKGnZfb+OQ1Bi7pfhRG+GK1r9Wqco2au7PLEgPqJf10dnw we9YYsY6HPtS9xGDfRsIi2tas+9Bz8dhx/rOT3RYmPdCg728qvwbV//U60LWzHivOHzI= Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The latest gcc-7.0.1 snapshot points out that we if nr_ch is zero, we never initialize some variables: sound/pci/au88x0/au88x0_core.c: In function 'vortex_adb_allocroute': sound/pci/au88x0/au88x0_core.c:2304:68: error: 'mix[0]' may be used uninitialized in this function [-Werror=maybe-uninitialized] sound/pci/au88x0/au88x0_core.c:2305:58: error: 'src[0]' may be used uninitialized in this function [-Werror=maybe-uninitialized] I assume this can never happen in practice, but adding a check here doesn't hurt either and avoids the warning. The code has been unchanged since the start of git history. Signed-off-by: Arnd Bergmann --- sound/pci/au88x0/au88x0_core.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/sound/pci/au88x0/au88x0_core.c b/sound/pci/au88x0/au88x0_core.c index e1af24f87566..c308a4f70550 100644 --- a/sound/pci/au88x0/au88x0_core.c +++ b/sound/pci/au88x0/au88x0_core.c @@ -2279,6 +2279,9 @@ vortex_adb_allocroute(vortex_t *vortex, int dma, int nr_ch, int dir, } else { int src[2], mix[2]; + if (nr_ch < 1) + return -EINVAL; + /* Get SRC and MIXER hardware resources. */ for (i = 0; i < nr_ch; i++) { if ((mix[i] = -- 2.9.0