Skip to contentSkip to conversation

ALSA: allocation may fail in snd_pcm_oss_change_params()

PATCH In review Roel Kluin 2 participants 2 messages Aug 31, 2009 Sound

lore
Share & tools
lore

Roel Kluin

author
#0 lore raw

PATCH 1/1 ALSA: allocation may fail in snd_pcm_oss_change_params()

Allocation may fail, show if it did.

---

sound/core/oss/pcm_oss.c +4 -0
index dbe406b..ea91a0a 100644
@@ -1047,6 +1047,10 @@ static int snd_pcm_oss_change_params(struct snd_pcm_substream *substream)
 	runtime->oss.prepare = 1;
 	vfree(runtime->oss.buffer);
 	runtime->oss.buffer = vmalloc(runtime->oss.period_bytes);
+	if (runtime->oss.buffer == NULL) {
+		err = -ENOMEM;
+		goto failure;
+	}
 	runtime->oss.buffer_used = 0;
 	if (runtime->dma_area)
 		snd_pcm_format_set_silence(runtime->format, runtime->dma_area, bytes_to_samples(runtime, runtime->dma_bytes));
#1 lore raw

At Mon, 31 Aug 2009 16:23:53 +0200,

Quoted 2 lines · Roel Kluin

Allocation may fail, show if it did.

Thanks for the patch.
But this isn't enough and still may lead to an error in the rest because it clears the flag runtime->oss.params before the error path.

I applied with that fix now.

Takashi

Quoted 22 lines

---

sound/core/oss/pcm_oss.c +4 -0
index dbe406b..ea91a0a 100644
@@ -1047,6 +1047,10 @@ static int snd_pcm_oss_change_params(struct snd_pcm_substream *substream)
 	runtime->oss.prepare = 1;
 	vfree(runtime->oss.buffer);
 	runtime->oss.buffer = vmalloc(runtime->oss.period_bytes);
+	if (runtime->oss.buffer == NULL) {
+		err = -ENOMEM;
+		goto failure;
+	}
 	runtime->oss.buffer_used = 0;
 	if (runtime->dma_area)
 		snd_pcm_format_set_silence(runtime->format, runtime->dma_area, bytes_to_samples(runtime, runtime->dma_bytes));

_______________________________________________
Alsa-devel mailing list
[email protected]
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel