Skip to content

Commit b9a4efd

Browse files
perexgtiwai
authored andcommitted
ALSA: ice1712,ice1724: fix the kcontrol->id initialization
The new xarray lookup code requires to know complete kcontrol->id before snd_ctl_add() call. Reorder the code to make the initialization properly. Cc: [email protected] # v5.19+ Reported-by: Martin Zidek <[email protected]> Signed-off-by: Jaroslav Kysela <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Takashi Iwai <[email protected]>
1 parent da209f7 commit b9a4efd

File tree

3 files changed

+23
-14
lines changed

3 files changed

+23
-14
lines changed

sound/pci/ice1712/aureon.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1899,11 +1899,12 @@ static int aureon_add_controls(struct snd_ice1712 *ice)
18991899
else {
19001900
for (i = 0; i < ARRAY_SIZE(cs8415_controls); i++) {
19011901
struct snd_kcontrol *kctl;
1902-
err = snd_ctl_add(ice->card, (kctl = snd_ctl_new1(&cs8415_controls[i], ice)));
1903-
if (err < 0)
1904-
return err;
1902+
kctl = snd_ctl_new1(&cs8415_controls[i], ice);
19051903
if (i > 1)
19061904
kctl->id.device = ice->pcm->device;
1905+
err = snd_ctl_add(ice->card, kctl);
1906+
if (err < 0)
1907+
return err;
19071908
}
19081909
}
19091910
}

sound/pci/ice1712/ice1712.c

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2371,22 +2371,26 @@ int snd_ice1712_spdif_build_controls(struct snd_ice1712 *ice)
23712371

23722372
if (snd_BUG_ON(!ice->pcm_pro))
23732373
return -EIO;
2374-
err = snd_ctl_add(ice->card, kctl = snd_ctl_new1(&snd_ice1712_spdif_default, ice));
2374+
kctl = snd_ctl_new1(&snd_ice1712_spdif_default, ice);
2375+
kctl->id.device = ice->pcm_pro->device;
2376+
err = snd_ctl_add(ice->card, kctl);
23752377
if (err < 0)
23762378
return err;
2379+
kctl = snd_ctl_new1(&snd_ice1712_spdif_maskc, ice);
23772380
kctl->id.device = ice->pcm_pro->device;
2378-
err = snd_ctl_add(ice->card, kctl = snd_ctl_new1(&snd_ice1712_spdif_maskc, ice));
2381+
err = snd_ctl_add(ice->card, kctl);
23792382
if (err < 0)
23802383
return err;
2384+
kctl = snd_ctl_new1(&snd_ice1712_spdif_maskp, ice);
23812385
kctl->id.device = ice->pcm_pro->device;
2382-
err = snd_ctl_add(ice->card, kctl = snd_ctl_new1(&snd_ice1712_spdif_maskp, ice));
2386+
err = snd_ctl_add(ice->card, kctl);
23832387
if (err < 0)
23842388
return err;
2389+
kctl = snd_ctl_new1(&snd_ice1712_spdif_stream, ice);
23852390
kctl->id.device = ice->pcm_pro->device;
2386-
err = snd_ctl_add(ice->card, kctl = snd_ctl_new1(&snd_ice1712_spdif_stream, ice));
2391+
err = snd_ctl_add(ice->card, kctl);
23872392
if (err < 0)
23882393
return err;
2389-
kctl->id.device = ice->pcm_pro->device;
23902394
ice->spdif.stream_ctl = kctl;
23912395
return 0;
23922396
}

sound/pci/ice1712/ice1724.c

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2392,23 +2392,27 @@ static int snd_vt1724_spdif_build_controls(struct snd_ice1712 *ice)
23922392
if (err < 0)
23932393
return err;
23942394

2395-
err = snd_ctl_add(ice->card, kctl = snd_ctl_new1(&snd_vt1724_spdif_default, ice));
2395+
kctl = snd_ctl_new1(&snd_vt1724_spdif_default, ice);
2396+
kctl->id.device = ice->pcm->device;
2397+
err = snd_ctl_add(ice->card, kctl);
23962398
if (err < 0)
23972399
return err;
2400+
kctl = snd_ctl_new1(&snd_vt1724_spdif_maskc, ice);
23982401
kctl->id.device = ice->pcm->device;
2399-
err = snd_ctl_add(ice->card, kctl = snd_ctl_new1(&snd_vt1724_spdif_maskc, ice));
2402+
err = snd_ctl_add(ice->card, kctl);
24002403
if (err < 0)
24012404
return err;
2405+
kctl = snd_ctl_new1(&snd_vt1724_spdif_maskp, ice);
24022406
kctl->id.device = ice->pcm->device;
2403-
err = snd_ctl_add(ice->card, kctl = snd_ctl_new1(&snd_vt1724_spdif_maskp, ice));
2407+
err = snd_ctl_add(ice->card, kctl);
24042408
if (err < 0)
24052409
return err;
2406-
kctl->id.device = ice->pcm->device;
24072410
#if 0 /* use default only */
2408-
err = snd_ctl_add(ice->card, kctl = snd_ctl_new1(&snd_vt1724_spdif_stream, ice));
2411+
kctl = snd_ctl_new1(&snd_vt1724_spdif_stream, ice);
2412+
kctl->id.device = ice->pcm->device;
2413+
err = snd_ctl_add(ice->card, kctl);
24092414
if (err < 0)
24102415
return err;
2411-
kctl->id.device = ice->pcm->device;
24122416
ice->spdif.stream_ctl = kctl;
24132417
#endif
24142418
return 0;

0 commit comments

Comments
 (0)