Skip to content

Commit d10ee9c

Browse files
srikanthkorangalaharitiwai
authored andcommitted
ALSA: timer: catch invalid timer object creation
A timer object for the classes SNDRV_TIMER_CLASS_CARD and SNDRV_TIMER_CLASS_PCM has to be associated with a card object, but we have no check at creation time. Such a timer object with NULL card causes various unexpected problems, e.g. NULL dereference at reading the sound timer proc file. So as preventive measure while the creating the sound timer object is created the card information availability is checked for the mentioned entries and returned error if its NULL. Signed-off-by: Srikanth K H <[email protected]> Signed-off-by: Takashi Iwai <[email protected]>
1 parent 7abeb64 commit d10ee9c

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

sound/core/timer.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -883,6 +883,11 @@ int snd_timer_new(struct snd_card *card, char *id, struct snd_timer_id *tid,
883883

884884
if (snd_BUG_ON(!tid))
885885
return -EINVAL;
886+
if (tid->dev_class == SNDRV_TIMER_CLASS_CARD ||
887+
tid->dev_class == SNDRV_TIMER_CLASS_PCM) {
888+
if (WARN_ON(!card))
889+
return -EINVAL;
890+
}
886891
if (rtimer)
887892
*rtimer = NULL;
888893
timer = kzalloc(sizeof(*timer), GFP_KERNEL);

0 commit comments

Comments
 (0)