Skip to contentSkip to conversation

ALSA: lola: add a check for the return of vmalloc()

PATCH Applied [email protected] 2 participants 2 messages Mar 4, 2022 Sound

v1 of 3 Applied Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ALSA: lola: add a check for the return of vmalloc()

From: Xiaoke Wang <[email protected]>

vmalloc() is a memory allocation function which can return NULL when some internal memory errors happen. So it is better to check the return of it to catch the error in time.

---
 sound/pci/lola/lola_mixer.c | 2 ++
 1 file changed, 2 insertions(+)
sound/pci/lola/lola_mixer.c +2 -0
index e2c8f14..6b16248 100644
@@ -121,6 +121,8 @@ int lola_init_mixer_widget(struct lola *chip, int nid)
 
 	/* reserve memory to copy mixer data for sleep mode transitions */
 	chip->mixer.array_saved = vmalloc(sizeof(struct lola_mixer_array));
+	if (!chip->mixer.array_saved)
+		return -ENOMEM;
 
 	/* mixer matrix sources are physical input data and play streams */
 	chip->mixer.src_stream_outs = chip->pcm[PLAY].num_streams;