mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: xkernel <xkernel.wang@foxmail.com>
To: perex@perex.cz, tiwai@suse.com
Cc: alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org,
	xkernel <xkernel.wang@foxmail.com>
Subject: [PATCH] ALSA: jack: Check the return value of kstrdup()
Date: Sun, 12 Dec 2021 01:13:26 +0800	[thread overview]
Message-ID: <tencent_3D368E118A8AF018A5B1FF16904166B2DC07@qq.com> (raw)

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) {
-- 


             reply	other threads:[~2021-12-11 19:18 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-11 17:13 xkernel [this message]
2021-12-12  5:44 ` Joe Perches
2021-12-13  7:39 Xiaoke Wang
2021-12-13  9:40 ` Takashi Iwai

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=tencent_3D368E118A8AF018A5B1FF16904166B2DC07@qq.com \
    --to=xkernel.wang@foxmail.com \
    --cc=alsa-devel@alsa-project.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=perex@perex.cz \
    --cc=tiwai@suse.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®