From: Joe Perches <joe@perches.com>
To: xkernel <xkernel.wang@foxmail.com>, perex@perex.cz, tiwai@suse.com
Cc: alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] ALSA: jack: Check the return value of kstrdup()
Date: Sat, 11 Dec 2021 21:44:33 -0800 [thread overview]
Message-ID: <64e31a014f01755c618c9d126f006b01fbc66408.camel@perches.com> (raw)
In-Reply-To: <tencent_3D368E118A8AF018A5B1FF16904166B2DC07@qq.com>
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) {
next prev parent reply other threads:[~2021-12-12 5:44 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-12-11 17:13 xkernel
2021-12-12 5:44 ` Joe Perches [this message]
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=64e31a014f01755c618c9d126f006b01fbc66408.camel@perches.com \
--to=joe@perches.com \
--cc=alsa-devel@alsa-project.org \
--cc=linux-kernel@vger.kernel.org \
--cc=perex@perex.cz \
--cc=tiwai@suse.com \
--cc=xkernel.wang@foxmail.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®