Skip to content

Commit

Permalink
ALSA: jack: Check the return value of kstrdup()
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
x2018 authored and tiwai committed Dec 13, 2021
1 parent 2dee54b commit c01c1db
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions sound/core/jack.c
Original file line number Diff line number Diff line change
Expand Up @@ -509,6 +509,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 c01c1db

Please sign in to comment.