From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754848AbZKKHIa (ORCPT ); Wed, 11 Nov 2009 02:08:30 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1753551AbZKKHI3 (ORCPT ); Wed, 11 Nov 2009 02:08:29 -0500 Received: from cantor2.suse.de ([195.135.220.15]:46859 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753241AbZKKHI3 (ORCPT ); Wed, 11 Nov 2009 02:08:29 -0500 Date: Wed, 11 Nov 2009 08:08:33 +0100 Message-ID: From: Takashi Iwai To: Roel Kluin Cc: Jaroslav Kysela , alsa-devel@alsa-project.org, Andrew Morton , LKML Subject: Re: [PATCH] ALSA: possible read past array alc88[02]_parse_auto_config() In-Reply-To: <4AF9BAFB.3090403@gmail.com> References: <4AF9BAFB.3090403@gmail.com> User-Agent: Wanderlust/2.15.6 (Almost Unreal) SEMI/1.14.6 (Maruoka) FLIM/1.14.9 (=?UTF-8?B?R29qxY0=?=) APEL/10.7 Emacs/23.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 At Tue, 10 Nov 2009 20:11:55 +0100, Roel Kluin wrote: > > The test of index `i' is after the read - too late - and > unsafe: if snd_hda_get_connections() fails in the last > iteration a read beyond the array is possible. > > Signed-off-by: Roel Kluin Applied now. Thanks! Takashi > --- > sound/pci/hda/patch_realtek.c | 8 ++++---- > 1 files changed, 4 insertions(+), 4 deletions(-) > > diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c > index ff20048..fd094f5 100644 > --- a/sound/pci/hda/patch_realtek.c > +++ b/sound/pci/hda/patch_realtek.c > @@ -4684,9 +4684,9 @@ static int alc880_parse_auto_config(struct hda_codec *codec) > spec->multiout.dig_out_nid = dig_nid; > else { > spec->multiout.slave_dig_outs = spec->slave_dig_outs; > - spec->slave_dig_outs[i - 1] = dig_nid; > - if (i == ARRAY_SIZE(spec->slave_dig_outs) - 1) > + if (i >= ARRAY_SIZE(spec->slave_dig_outs) - 1) > break; > + spec->slave_dig_outs[i - 1] = dig_nid; > } > } > if (spec->autocfg.dig_in_pin) > @@ -9813,9 +9813,9 @@ static int alc882_parse_auto_config(struct hda_codec *codec) > spec->multiout.dig_out_nid = dig_nid; > else { > spec->multiout.slave_dig_outs = spec->slave_dig_outs; > - spec->slave_dig_outs[i - 1] = dig_nid; > - if (i == ARRAY_SIZE(spec->slave_dig_outs) - 1) > + if (i >= ARRAY_SIZE(spec->slave_dig_outs) - 1) > break; > + spec->slave_dig_outs[i - 1] = dig_nid; > } > } > if (spec->autocfg.dig_in_pin) >