Skip to content

Commit

Permalink
ALSA: jack: Check the return value of kstrdup()
Browse files Browse the repository at this point in the history
commit c01c1db upstream.

kstrdup() can return NULL, it is better to check the return value of it.

Signed-off-by: Xiaoke Wang <xkernel.wang@foxmail.com>
Cc: <stable@vger.kernel.org>
Link: https://lore.kernel.org/r/tencent_094816F3522E0DC704056C789352EBBF0606@qq.com
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
x2018 authored and gregkh committed Dec 29, 2021
1 parent 51c7b2a commit a96c08e
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions sound/core/jack.c
Expand Up @@ -220,6 +220,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) {
Expand Down

0 comments on commit a96c08e

Please sign in to comment.