alsa-devel.alsa-project.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] ALSA: timer: Fix master timer notification
@ 2021-06-02 11:38 Takashi Iwai
  2021-06-02 16:58 ` Jaroslav Kysela
  0 siblings, 1 reply; 2+ messages in thread
From: Takashi Iwai @ 2021-06-02 11:38 UTC (permalink / raw)
  To: alsa-devel

snd_timer_notify1() calls the notification to each slave for a master
event, but it passes a wrong event number.  It should be +10 offset,
corresponding to SNDRV_TIMER_EVENT_MXXX, but it's incorrectly with
+100 offset.  Casually this was spotted by UBSAN check via syzkaller.

Reported-by: syzbot+d102fa5b35335a7e544e@syzkaller.appspotmail.com
Cc: <stable@vger.kernel.org>
Link: https://lore.kernel.org/r/000000000000e5560e05c3bd1d63@google.com
Signed-off-by: Takashi Iwai <tiwai@suse.de>
---
 sound/core/timer.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/sound/core/timer.c b/sound/core/timer.c
index 6898b1ac0d7f..92b7008fcdb8 100644
--- a/sound/core/timer.c
+++ b/sound/core/timer.c
@@ -520,9 +520,10 @@ static void snd_timer_notify1(struct snd_timer_instance *ti, int event)
 		return;
 	if (timer->hw.flags & SNDRV_TIMER_HW_SLAVE)
 		return;
+	event += 10; /* convert to SNDRV_TIMER_EVENT_MXXX */
 	list_for_each_entry(ts, &ti->slave_active_head, active_list)
 		if (ts->ccallback)
-			ts->ccallback(ts, event + 100, &tstamp, resolution);
+			ts->ccallback(ts, event, &tstamp, resolution);
 }
 
 /* start/continue a master timer */
-- 
2.26.2


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] ALSA: timer: Fix master timer notification
  2021-06-02 11:38 [PATCH] ALSA: timer: Fix master timer notification Takashi Iwai
@ 2021-06-02 16:58 ` Jaroslav Kysela
  0 siblings, 0 replies; 2+ messages in thread
From: Jaroslav Kysela @ 2021-06-02 16:58 UTC (permalink / raw)
  To: Takashi Iwai, alsa-devel; +Cc: stable

On 02. 06. 21 13:38, Takashi Iwai wrote:
> snd_timer_notify1() calls the notification to each slave for a master
> event, but it passes a wrong event number.  It should be +10 offset,
> corresponding to SNDRV_TIMER_EVENT_MXXX, but it's incorrectly with
> +100 offset.  Casually this was spotted by UBSAN check via syzkaller.
> 
> Reported-by: syzbot+d102fa5b35335a7e544e@syzkaller.appspotmail.com
> Cc: <stable@vger.kernel.org>
> Link: https://lore.kernel.org/r/000000000000e5560e05c3bd1d63@google.com
> Signed-off-by: Takashi Iwai <tiwai@suse.de>

Reviewed-by: Jaroslav Kysela <perex@perex.cz>

> ---
>  sound/core/timer.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/sound/core/timer.c b/sound/core/timer.c
> index 6898b1ac0d7f..92b7008fcdb8 100644
> --- a/sound/core/timer.c
> +++ b/sound/core/timer.c
> @@ -520,9 +520,10 @@ static void snd_timer_notify1(struct snd_timer_instance *ti, int event)
>  		return;
>  	if (timer->hw.flags & SNDRV_TIMER_HW_SLAVE)
>  		return;
> +	event += 10; /* convert to SNDRV_TIMER_EVENT_MXXX */
>  	list_for_each_entry(ts, &ti->slave_active_head, active_list)
>  		if (ts->ccallback)
> -			ts->ccallback(ts, event + 100, &tstamp, resolution);
> +			ts->ccallback(ts, event, &tstamp, resolution);
>  }
>  
>  /* start/continue a master timer */
> 


-- 
Jaroslav Kysela <perex@perex.cz>
Linux Sound Maintainer; ALSA Project; Red Hat, Inc.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-06-02 16:59 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-02 11:38 [PATCH] ALSA: timer: Fix master timer notification Takashi Iwai
2021-06-02 16:58 ` Jaroslav Kysela

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).