[PATCH] ALSA: jack: Check the return value of kstrdup()
![](https://secure.gravatar.com/avatar/741a6227d5e4ea0935970b2c0f786b11.jpg?s=120&d=mm&r=g)
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) {
![](https://secure.gravatar.com/avatar/98ef9b90d87d8444e08034e5e5c70d1b.jpg?s=120&d=mm&r=g)
On Sun, 2021-12-12 at 01:13 +0800, xkernel wrote:
kstrdup() can return NULL, it is better to check the return value of it.
[]
diff --git 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;
jack should be freed too.
if (!jack->id) { kfree(jack); return -ENOMEM; }
/* don't creat input device for phantom jack */ if (!phantom_jack) {
participants (2)
-
Joe Perches
-
xkernel