From: Xiaoke Wang Date: Mon, 13 Dec 2021 07:39:31 +0000 (+0800) Subject: ALSA: jack: Check the return value of kstrdup() X-Git-Tag: v4.4.297~8 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=29533bbddd799352b2c9ad0568533e536d1baaec;p=thirdparty%2Fkernel%2Fstable.git ALSA: jack: Check the return value of kstrdup() commit c01c1db1dc632edafb0dff32d40daf4f9c1a4e19 upstream. kstrdup() can return NULL, it is better to check the return value of it. Signed-off-by: Xiaoke Wang Cc: Link: https://lore.kernel.org/r/tencent_094816F3522E0DC704056C789352EBBF0606@qq.com Signed-off-by: Takashi Iwai Signed-off-by: Greg Kroah-Hartman --- diff --git a/sound/core/jack.c b/sound/core/jack.c index 7237acbdcbbc8..fcc972fbe8ffd 100644 --- a/sound/core/jack.c +++ b/sound/core/jack.c @@ -227,6 +227,10 @@ int snd_jack_new(struct snd_card *card, const char *id, int type, return -ENOMEM; jack->id = kstrdup(id, GFP_KERNEL); + if (jack->id == NULL) { + kfree(jack); + return -ENOMEM; + } /* don't creat input device for phantom jack */ if (!phantom_jack) {