Alsa-Devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] ALSA: lola: add a check for the return of vmalloc()
@ 2022-03-04  8:38 xkernel.wang
  2022-03-04  8:51 ` Takashi Iwai
  0 siblings, 1 reply; 2+ messages in thread
From: xkernel.wang @ 2022-03-04  8:38 UTC (permalink / raw)
  To: perex, tiwai; +Cc: alsa-devel, linux-kernel, Xiaoke Wang

From: Xiaoke Wang <xkernel.wang@foxmail.com>

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.

Signed-off-by: Xiaoke Wang <xkernel.wang@foxmail.com>
---
 sound/pci/lola/lola_mixer.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/sound/pci/lola/lola_mixer.c b/sound/pci/lola/lola_mixer.c
index e2c8f14..6b16248 100644
--- a/sound/pci/lola/lola_mixer.c
+++ b/sound/pci/lola/lola_mixer.c
@@ -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;
-- 

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

* Re: [PATCH] ALSA: lola: add a check for the return of vmalloc()
  2022-03-04  8:38 [PATCH] ALSA: lola: add a check for the return of vmalloc() xkernel.wang
@ 2022-03-04  8:51 ` Takashi Iwai
  0 siblings, 0 replies; 2+ messages in thread
From: Takashi Iwai @ 2022-03-04  8:51 UTC (permalink / raw)
  To: xkernel.wang; +Cc: linux-kernel, alsa-devel, tiwai

On Fri, 04 Mar 2022 09:38:20 +0100,
xkernel.wang@foxmail.com wrote:
> 
> From: Xiaoke Wang <xkernel.wang@foxmail.com>
> 
> 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.
> 
> Signed-off-by: Xiaoke Wang <xkernel.wang@foxmail.com>

Thanks, applied.


Takashi

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

end of thread, other threads:[~2022-03-04  8:52 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-03-04  8:38 [PATCH] ALSA: lola: add a check for the return of vmalloc() xkernel.wang
2022-03-04  8:51 ` Takashi Iwai

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox