ALSA: missing check for possible NULL after the call to kstrdup
PATCH 1/1 ALSA: missing check for possible NULL after the call to kstrdup
From: Austin Kim <[email protected]>
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.
--- sound/synth/emux/emux.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
sound/synth/emux/emux.c +1 -1
@@ -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 */
Signature · 1 line
2.20.1
Takashi Iwai
AppliedQuoted 8 lines · Austin Kim
From: Austin Kim <[email protected]>
If
kcalloc()return NULL due to memory starvation, it is possible forkstrdup()to return NULL in similar case. So add null check after the call tokstrdup()is made.Signed-off-by Austin Kim <[email protected]>
Thanks, applied now with a minor coding-style fix (we need no extra parentheses), the correction of the subject line with the proper prefix, and the addition of Cc-to-stable.
Takashi
2021년 11월 9일 (화) 오후 3:24, Takashi Iwai <[email protected]>님이 작성:
Quoted 10 lines
Quoted 7 lines · Austin Kim
From: Austin Kim <[email protected]>
If
kcalloc()return NULL due to memory starvation, it is possible forkstrdup()to return NULL in similar case. So add null check after the call tokstrdup()is made.
Quoted 6 lines
Quoted 1 line
Signed-off-by Austin Kim <[email protected]>Thanks, applied now with a minor coding-style fix (we need no extra parentheses), the correction of the subject line with the proper prefix, and the addition of Cc-to-stable.
Great, Thanks
BR,
Austin Kim
Quoted 2 lines
Takashi