Skip to contentSkip to conversation

sound: atom: fix a missing check of snd_pcm_lib_malloc_pages

PATCH In review Kangjie Lu 4 participants 4 messages Dec 26, 2018 – Jan 7, 2019

Subsystems (3)
lore
Share & tools
lore

Kangjie Lu

author
#0 lore raw

PATCH 1/1 sound: atom: fix a missing check of snd_pcm_lib_malloc_pages

snd_pcm_lib_malloc_pages() may fail, so let's check its status and return its error code upstream.

---
 sound/soc/intel/atom/sst-mfld-platform-pcm.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
sound/soc/intel/atom/sst-mfld-platform-pcm.c +7 -1
index afc559866095..91a2436ce952 100644
@@ -399,7 +399,13 @@ static int sst_media_hw_params(struct snd_pcm_substream *substream,
 				struct snd_pcm_hw_params *params,
 				struct snd_soc_dai *dai)
 {
-	snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(params));
+	int ret;
+
+	ret =
+		snd_pcm_lib_malloc_pages(substream,
+				params_buffer_bytes(params));
+	if (ret)
+		return ret;
 	memset(substream->runtime->dma_area, 0, params_buffer_bytes(params));
 	return 0;
 }
Signature · 1 line
2.17.2 (Apple Git-113)
Acked-by on v1 1/1
#1 lore raw
Quoted 2 lines · Kangjie Lu

snd_pcm_lib_malloc_pages() may fail, so let's check its status and return its error code upstream.

Quoted 25 lines
---
  sound/soc/intel/atom/sst-mfld-platform-pcm.c | 8 +++++++-
  1 file changed, 7 insertions(+), 1 deletion(-)
sound/soc/intel/atom/sst-mfld-platform-pcm.c +7 -1
index afc559866095..91a2436ce952 100644
@@ -399,7 +399,13 @@ static int sst_media_hw_params(struct snd_pcm_substream *substream,
  				struct snd_pcm_hw_params *params,
  				struct snd_soc_dai *dai)
  {
-	snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(params));
+	int ret;
+
+	ret =
+		snd_pcm_lib_malloc_pages(substream,
+				params_buffer_bytes(params));
+	if (ret)
+		return ret;
  	memset(substream->runtime->dma_area, 0, params_buffer_bytes(params));
  	return 0;
  }
#2 lore raw
Quoted 7 lines · Pierre-Louis Bossart
Quoted 2 lines · Kangjie Lu

snd_pcm_lib_malloc_pages() may fail, so let's check its status and return its error code upstream.

This fixes a potential kernel Oops. Mark, please put Cc to stable when applying.

thanks,

Takashi

Quoted 28 lines
Quoted 27 lines
---
  sound/soc/intel/atom/sst-mfld-platform-pcm.c | 8 +++++++-
  1 file changed, 7 insertions(+), 1 deletion(-)
sound/soc/intel/atom/sst-mfld-platform-pcm.c +7 -1
index afc559866095..91a2436ce952 100644
@@ -399,7 +399,13 @@ static int sst_media_hw_params(struct snd_pcm_substream *substream,
  				struct snd_pcm_hw_params *params,
  				struct snd_soc_dai *dai)
  {
-	snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(params));
+	int ret;
+
+	ret =
+		snd_pcm_lib_malloc_pages(substream,
+				params_buffer_bytes(params));
+	if (ret)
+		return ret;
  	memset(substream->runtime->dma_area, 0, params_buffer_bytes(params));
  	return 0;
  }
maintainer
#3 lore raw
In reply to Kangjie Lu
Quoted 2 lines · Kangjie Lu

snd_pcm_lib_malloc_pages() may fail, so let's check its status and return its error code upstream.

Please use subject lines matching the style for the subsystem. This makes it easier for people to identify relevant patches.