All of lore.kernel.org
 help / color / mirror / Atom feed
From: Xiaoke Wang <xkernel.wang@foxmail.com>
To: joe@perches.com, perex@perex.cz, tiwai@suse.com
Cc: alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org,
	Xiaoke Wang <xkernel.wang@foxmail.com>
Subject: Re: [PATCH] ALSA: jack: Check the return value of kstrdup()
Date: Mon, 13 Dec 2021 15:39:31 +0800	[thread overview]
Message-ID: <tencent_094816F3522E0DC704056C789352EBBF0606@qq.com> (raw)

kstrdup() can return NULL, it is better to check the return value of it.
Fix: free jack and use my full name.

Signed-off-by: Xiaoke Wang <xkernel.wang@foxmail.com>
---
 sound/core/jack.c | 4 ++
 1 file changed, 4 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,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) {
-- 


             reply	other threads:[~2021-12-13  7:40 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-13  7:39 Xiaoke Wang [this message]
2021-12-13  9:40 ` [PATCH] ALSA: jack: Check the return value of kstrdup() Takashi Iwai
2021-12-13  9:40   ` Takashi Iwai
  -- strict thread matches above, loose matches on Subject: below --
2021-12-11 17:13 xkernel
2021-12-12  5:44 ` Joe Perches

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_094816F3522E0DC704056C789352EBBF0606@qq.com \
    --to=xkernel.wang@foxmail.com \
    --cc=alsa-devel@alsa-project.org \
    --cc=joe@perches.com \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.