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
Xiaoke Wang authored and Greg Kroah-Hartman committed Dec 29, 2021
1 parent efe8f55 commit be3e564
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 @@ -234,6 +234,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 be3e564

Please sign in to comment.