Skip to contentSkip to conversation

ALSA: synth: emux: soundfont.c: divide by zero in calc_gus_envelope_time()

PATCH Applied Dan Carpenter 2 participants 2 messages May 6, 2019

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ALSA: synth: emux: soundfont.c: divide by zero in calc_gus_envelope_time()

This function is called from load_guspatch() and the rate is specified by the user. If they accidentally selected zero then it would crash the kernel. I've just changed the zero to a one.

---
 sound/synth/emux/soundfont.c | 2 ++
 1 file changed, 2 insertions(+)
sound/synth/emux/soundfont.c +2 -0
index 31a4ea94830e..9b5d70104489 100644
@@ -856,6 +856,8 @@ calc_gus_envelope_time(int rate, int start, int end)
 	int r, p, t;
 	r = (3 - ((rate >> 6) & 3)) * 3;
 	p = rate & 0x3f;
+	if (!p)
+		p = 1;
 	t = end - start;
 	if (t < 0) t = -t;
 	if (13 > r)
Signature · 1 line
2.18.0
Applied
#1 lore raw
Quoted 6 lines · Dan Carpenter

This function is called from load_guspatch() and the rate is specified by the user. If they accidentally selected zero then it would crash the kernel. I've just changed the zero to a one.

Thanks, applied now.

Takashi

Quoted 21 lines
---
 sound/synth/emux/soundfont.c | 2 ++
 1 file changed, 2 insertions(+)
sound/synth/emux/soundfont.c +2 -0
index 31a4ea94830e..9b5d70104489 100644
@@ -856,6 +856,8 @@ calc_gus_envelope_time(int rate, int start, int end)
 	int r, p, t;
 	r = (3 - ((rate >> 6) & 3)) * 3;
 	p = rate & 0x3f;
+	if (!p)
+		p = 1;
 	t = end - start;
 	if (t < 0) t = -t;
 	if (13 > r)
Signature · 1 line
2.18.0