Skip to content

Commit fe08f34

Browse files
committed
ALSA: pcm: Remove incorrect snd_BUG_ON() usages
syzkaller triggered kernel warnings through PCM OSS emulation at closing a stream: WARNING: CPU: 0 PID: 3502 at sound/core/pcm_lib.c:1635 snd_pcm_hw_param_first+0x289/0x690 sound/core/pcm_lib.c:1635 Call Trace: .... snd_pcm_hw_param_near.constprop.27+0x78d/0x9a0 sound/core/oss/pcm_oss.c:457 snd_pcm_oss_change_params+0x17d3/0x3720 sound/core/oss/pcm_oss.c:969 snd_pcm_oss_make_ready+0xaa/0x130 sound/core/oss/pcm_oss.c:1128 snd_pcm_oss_sync+0x257/0x830 sound/core/oss/pcm_oss.c:1638 snd_pcm_oss_release+0x20b/0x280 sound/core/oss/pcm_oss.c:2431 __fput+0x327/0x7e0 fs/file_table.c:210 .... This happens while it tries to open and set up the aloop device concurrently. The warning above (invoked from snd_BUG_ON() macro) is to detect the unexpected logical error where snd_pcm_hw_refine() call shouldn't fail. The theory is true for the case where the hw_params config rules are static. But for an aloop device, the hw_params rule condition does vary dynamically depending on the connected target; when another device is opened and changes the parameters, the device connected in another side is also affected, and it caused the error from snd_pcm_hw_refine(). That is, the simplest "solution" for this is to remove the incorrect assumption of static rules, and treat such an error as a normal error path. As there are a couple of other places using snd_BUG_ON() incorrectly, this patch removes these spurious snd_BUG_ON() calls. Reported-by: [email protected] Cc: <[email protected]> Signed-off-by: Takashi Iwai <[email protected]>
1 parent 44be77c commit fe08f34

File tree

2 files changed

+2
-3
lines changed

2 files changed

+2
-3
lines changed

sound/core/oss/pcm_oss.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -455,7 +455,6 @@ static int snd_pcm_hw_param_near(struct snd_pcm_substream *pcm,
455455
v = snd_pcm_hw_param_last(pcm, params, var, dir);
456456
else
457457
v = snd_pcm_hw_param_first(pcm, params, var, dir);
458-
snd_BUG_ON(v < 0);
459458
return v;
460459
}
461460

sound/core/pcm_lib.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1632,7 +1632,7 @@ int snd_pcm_hw_param_first(struct snd_pcm_substream *pcm,
16321632
return changed;
16331633
if (params->rmask) {
16341634
int err = snd_pcm_hw_refine(pcm, params);
1635-
if (snd_BUG_ON(err < 0))
1635+
if (err < 0)
16361636
return err;
16371637
}
16381638
return snd_pcm_hw_param_value(params, var, dir);
@@ -1678,7 +1678,7 @@ int snd_pcm_hw_param_last(struct snd_pcm_substream *pcm,
16781678
return changed;
16791679
if (params->rmask) {
16801680
int err = snd_pcm_hw_refine(pcm, params);
1681-
if (snd_BUG_ON(err < 0))
1681+
if (err < 0)
16821682
return err;
16831683
}
16841684
return snd_pcm_hw_param_value(params, var, dir);

0 commit comments

Comments
 (0)