From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934719AbdCXLCY (ORCPT ); Fri, 24 Mar 2017 07:02:24 -0400 Received: from mx2.suse.de ([195.135.220.15]:41564 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753231AbdCXLCH (ORCPT ); Fri, 24 Mar 2017 07:02:07 -0400 Date: Fri, 24 Mar 2017 12:02:04 +0100 Message-ID: From: Takashi Iwai To: "Arnd Bergmann" Cc: "Jaroslav Kysela" , , "Colin Ian King" , Subject: Re: [PATCH] ALSA: au88x0: avoid theoretical uninitialized access In-Reply-To: <20170323151607.636485-1-arnd@arndb.de> References: <20170323151607.636485-1-arnd@arndb.de> User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI/1.14.6 (Maruoka) FLIM/1.14.9 (=?UTF-8?B?R29qxY0=?=) APEL/10.8 Emacs/25.1 (x86_64-suse-linux-gnu) MULE/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Content-Type: text/plain; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 23 Mar 2017 16:15:55 +0100, Arnd Bergmann wrote: > > 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 Yeah, this shouldn't happen in practice, but better to cover. I applied the patch now. Thanks. Takashi > --- > 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 >