From: Austin Kim <austindh.kim@gmail.com>
To: tiwai@suse.com, perex@perex.cz
Cc: alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org,
austin.kim@lge.com
Subject: [PATCH] ALSA: missing check for possible NULL after the call to kstrdup
Date: Tue, 9 Nov 2021 00:37:42 +0000 [thread overview]
Message-ID: <20211109003742.GA5423@raspberrypi> (raw)
From: Austin Kim <austin.kim@lge.com>
If kcalloc() return NULL due to memory starvation, it is possible for
kstrdup() to return NULL in similar case. So add null check after the call
to kstrdup() is made.
Signed-off-by: Austin Kim <austin.kim@lge.com>
---
sound/synth/emux/emux.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/sound/synth/emux/emux.c b/sound/synth/emux/emux.c
index 49d1976a132c..6dab3c5bac00 100644
--- a/sound/synth/emux/emux.c
+++ b/sound/synth/emux/emux.c
@@ -88,7 +88,7 @@ int snd_emux_register(struct snd_emux *emu, struct snd_card *card, int index, ch
emu->name = kstrdup(name, GFP_KERNEL);
emu->voices = kcalloc(emu->max_voices, sizeof(struct snd_emux_voice),
GFP_KERNEL);
- if (emu->voices == NULL)
+ if ((emu->name == NULL) || (emu->voices == NULL))
return -ENOMEM;
/* create soundfont list */
--
2.20.1
next reply other threads:[~2021-11-09 7:00 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-11-09 0:37 Austin Kim [this message]
2021-11-09 6:24 ` [PATCH] ALSA: missing check for possible NULL after the call to kstrdup Takashi Iwai
2021-11-09 6:24 ` Takashi Iwai
2021-11-09 8:20 ` Austin Kim
2021-11-09 8:20 ` Austin Kim
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20211109003742.GA5423@raspberrypi \
--to=austindh.kim@gmail.com \
--cc=alsa-devel@alsa-project.org \
--cc=austin.kim@lge.com \
--cc=linux-kernel@vger.kernel.org \
--cc=perex@perex.cz \
--cc=tiwai@suse.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.