From: Joe Perches <joe@perches.com>
To: Duan Jiong <duanj.fnst@cn.fujitsu.com>
Cc: perex@perex.cz, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] ALSA: emu10k1: casting (void *) value returned by kcalloc is useless
Date: Wed, 04 Sep 2013 23:12:26 -0700 [thread overview]
Message-ID: <1378361546.1944.8.camel@joe-AO722> (raw)
In-Reply-To: <52281D37.40808@cn.fujitsu.com>
On Thu, 2013-09-05 at 13:57 +0800, Duan Jiong wrote:
> From: Duan Jiong <duanj.fnst@cn.fujitsu.com>
>
> Casting (void *) value returned by kcalloc is useless
> as mentioned in Documentation/CodingStyle, Chap 14.
__user is an important marker that is lost here.
> diff --git a/sound/pci/emu10k1/emufx.c b/sound/pci/emu10k1/emufx.c
[]
> @@ -1183,9 +1183,8 @@ static int _snd_emu10k1_audigy_init_efx(struct snd_emu10k1 *emu)
> mm_segment_t seg;
>
> if ((icode = kzalloc(sizeof(*icode), GFP_KERNEL)) == NULL ||
> - (icode->gpr_map = (u_int32_t __user *)
> - kcalloc(512 + 256 + 256 + 2 * 1024, sizeof(u_int32_t),
> - GFP_KERNEL)) == NULL ||
> + (icode->gpr_map = kcalloc(512 + 256 + 256 + 2 * 1024,
> + sizeof(u_int32_t), GFP_KERNEL)) == NULL ||
> (controls = kcalloc(SND_EMU10K1_GPR_CONTROLS,
> sizeof(*controls), GFP_KERNEL)) == NULL) {
> err = -ENOMEM;
I think this would be clearer as
err = -ENOMEM;
icode = kzalloc(sizeof(*icode), GFP_KERNEL)
if (!icode)
goto err;
icode->gpr_map = (__user)kcalloc(512 + 256 + 256 + 2 * 1024,
sizeof(u_int32_t), GFP_KERNEL);
if (!icode->gpr_map)
goto err;
controls = kcalloc(SND_EMU10K1_GPR_CONTROLS,
sizeof(*controls), GFP_KERNEL);
if (!controls)
goto err;
next prev parent reply other threads:[~2013-09-05 6:12 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-09-05 5:57 Duan Jiong
2013-09-05 6:12 ` Joe Perches [this message]
2013-09-05 10:10 ` Duan Jiong
2013-09-05 10:18 ` 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=1378361546.1944.8.camel@joe-AO722 \
--to=joe@perches.com \
--cc=duanj.fnst@cn.fujitsu.com \
--cc=linux-kernel@vger.kernel.org \
--cc=perex@perex.cz \
/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®