Message ID | 20160625110802.GA14579@localhost (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
On Sat, Jun 25, 2016 at 01:28:00PM +0200, Takashi Iwai wrote: > On Sat, 25 Jun 2016 13:08:02 +0200, > Bob Copeland wrote: > > > > Hi, > > > > I have UBSAN reporting an out-of-bounds array access (see below) on my > > machine. The following patch fixes the warning for me, but not sure if > > that is just papering over some other bug. Thanks in advance for looking! > > A better check would be to put > if (!path->depth) > continue; > before both path->path[0] and path->path[path->depth - 1] > evaluations. path->depth=1 cannot exist, but path->depth=0 might be. > > Could you resubmit with that fix? Sure, patch to follow in a separate mail so that patchwork can pick it up.
diff --git a/sound/pci/hda/hda_generic.c b/sound/pci/hda/hda_generic.c index 320445f3bf73..bc23a9d8e7b3 100644 --- a/sound/pci/hda/hda_generic.c +++ b/sound/pci/hda/hda_generic.c @@ -3978,7 +3978,7 @@ static hda_nid_t set_path_power(struct hda_codec *codec, hda_nid_t nid, for (n = 0; n < spec->paths.used; n++) { path = snd_array_elem(&spec->paths, n); if (path->path[0] == nid || - path->path[path->depth - 1] == nid) { + (path->depth > 0 && path->path[path->depth - 1] == nid)) { bool pin_old = path->pin_enabled; bool stream_old = path->stream_enabled;