Skip to content

Commit fd7df93

Browse files
tobluxtiwai
authored andcommitted
ALSA: aoa: Skip devices with no codecs in i2sbus_resume()
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>
1 parent edf04f1 commit fd7df93

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
@@ -405,6 +405,9 @@ static int i2sbus_resume(struct macio_dev* dev)
405405
int err, ret = 0;
406406

407407
list_for_each_entry(i2sdev, &control->list, item) {
408+
if (list_empty(&i2sdev->sound.codec_list))
409+
continue;
410+
408411
/* reset i2s bus format etc. */
409412
i2sbus_pcm_prepare_both(i2sdev);
410413

sound/aoa/soundbus/i2sbus/pcm.c

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

386+
cii = list_first_entry(&i2sdev->sound.codec_list,
387+
struct codec_info_item, list);
388+
386389
/* ok, let's set the serial format and stuff */
387390
switch (runtime->format) {
388391
/* 16 bit formats */
389392
case SNDRV_PCM_FORMAT_S16_BE:
390393
case SNDRV_PCM_FORMAT_U16_BE:
391394
/* FIXME: if we add different bus factors we need to
392395
* do more here!! */
393-
bi.bus_factor = 0;
394-
list_for_each_entry(cii, &i2sdev->sound.codec_list, list) {
395-
bi.bus_factor = cii->codec->bus_factor;
396-
break;
397-
}
398-
if (!bi.bus_factor)
399-
return -ENODEV;
396+
bi.bus_factor = cii->codec->bus_factor;
400397
input_16bit = 1;
401398
break;
402399
case SNDRV_PCM_FORMAT_S32_BE:
@@ -410,10 +407,7 @@ static int i2sbus_pcm_prepare(struct i2sbus_dev *i2sdev, int in)
410407
return -EINVAL;
411408
}
412409
/* we assume all sysclocks are the same! */
413-
list_for_each_entry(cii, &i2sdev->sound.codec_list, list) {
414-
bi.sysclock_factor = cii->codec->sysclock_factor;
415-
break;
416-
}
410+
bi.sysclock_factor = cii->codec->sysclock_factor;
417411

418412
if (clock_and_divisors(bi.sysclock_factor,
419413
bi.bus_factor,

0 commit comments

Comments
 (0)