Skip to content

Commit 69b3a50

Browse files
tobluxgregkh
authored andcommitted
ALSA: aoa: Skip devices with no codecs in i2sbus_resume()
[ Upstream commit fd7df93 ] In i2sbus_resume(), skip devices with an empty codec list, which avoids using an uninitialized 'sysclock_factor' in the 32-bit format path in i2sbus_pcm_prepare(). In i2sbus_pcm_prepare(), replace two list_for_each_entry() loops with a single list_first_entry() now that the codec list is guaranteed to be non-empty by all callers. Fixes: f3d9478 ("[ALSA] snd-aoa: add snd-aoa") Cc: stable@vger.kernel.org Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev> Link: https://patch.msgid.link/20260310102921.210109-3-thorsten.blum@linux.dev Signed-off-by: Takashi Iwai <tiwai@suse.de> Signed-off-by: Sasha Levin <sashal@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 32fbdb6 commit 69b3a50

2 files changed

Lines changed: 8 additions & 11 deletions

File tree

sound/aoa/soundbus/i2sbus/core.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -411,6 +411,9 @@ static int i2sbus_resume(struct macio_dev* dev)
411411
int err, ret = 0;
412412

413413
list_for_each_entry(i2sdev, &control->list, item) {
414+
if (list_empty(&i2sdev->sound.codec_list))
415+
continue;
416+
414417
/* reset i2s bus format etc. */
415418
i2sbus_pcm_prepare_both(i2sdev);
416419

sound/aoa/soundbus/i2sbus/pcm.c

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -411,20 +411,17 @@ static int i2sbus_pcm_prepare(struct i2sbus_dev *i2sdev, int in)
411411
/* set stop command */
412412
command->command = cpu_to_le16(DBDMA_STOP);
413413

414+
cii = list_first_entry(&i2sdev->sound.codec_list,
415+
struct codec_info_item, list);
416+
414417
/* ok, let's set the serial format and stuff */
415418
switch (runtime->format) {
416419
/* 16 bit formats */
417420
case SNDRV_PCM_FORMAT_S16_BE:
418421
case SNDRV_PCM_FORMAT_U16_BE:
419422
/* FIXME: if we add different bus factors we need to
420423
* do more here!! */
421-
bi.bus_factor = 0;
422-
list_for_each_entry(cii, &i2sdev->sound.codec_list, list) {
423-
bi.bus_factor = cii->codec->bus_factor;
424-
break;
425-
}
426-
if (!bi.bus_factor)
427-
return -ENODEV;
424+
bi.bus_factor = cii->codec->bus_factor;
428425
input_16bit = 1;
429426
break;
430427
case SNDRV_PCM_FORMAT_S32_BE:
@@ -438,10 +435,7 @@ static int i2sbus_pcm_prepare(struct i2sbus_dev *i2sdev, int in)
438435
return -EINVAL;
439436
}
440437
/* we assume all sysclocks are the same! */
441-
list_for_each_entry(cii, &i2sdev->sound.codec_list, list) {
442-
bi.sysclock_factor = cii->codec->sysclock_factor;
443-
break;
444-
}
438+
bi.sysclock_factor = cii->codec->sysclock_factor;
445439

446440
if (clock_and_divisors(bi.sysclock_factor,
447441
bi.bus_factor,

0 commit comments

Comments
 (0)