lkml.org 
[lkml]   [2021]   [Dec]   [11]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH] ALSA: jack: Check the return value of kstrdup()
Date
kstrdup() can return NULL, it is better to check the return value of it.

Signed-off-by: xkernel <xkernel.wang@foxmail.com>
---
sound/core/jack.c | 2 ++
1 file changed, 2 insertions(+)

diff --git a/sound/core/jack.c b/sound/core/jack.c
index 32350c6..5fd9954 100644
--- a/sound/core/jack.c
+++ b/sound/core/jack.c
@@ -509,6 +509,8 @@ 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)
+ return -ENOMEM;

/* don't creat input device for phantom jack */
if (!phantom_jack) {
--
\
 
 \ /
  Last update: 2021-12-11 20:19    [W:0.048 / U:0.128 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site