lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Date:	Thu, 05 Sep 2013 03:18:57 -0700
From:	Joe Perches <joe@...ches.com>
To:	Duan Jiong <duanj.fnst@...fujitsu.com>
Cc:	perex@...ex.cz, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] ALSA: emu10k1: casting (void *) value returned by
 kcalloc is useless

On Thu, 2013-09-05 at 18:10 +0800, Duan Jiong wrote:
> 于 2013年09月05日 14:12, Joe Perches 写道:
> > On Thu, 2013-09-05 at 13:57 +0800, Duan Jiong wrote:
> >> From: Duan Jiong <duanj.fnst@...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;
> > 
> 
> Maybe it should keep the original style, because i do as you said, and
> error messages appear during compiling the kernel.

I think your suggested patch causes sparse errors when
compiled with "$ make C=2 sound/pci/emu10k1/emufx.o"

And sorry, I just typed my reply in the email client and
I didn't compiled it or anything.

Most likely my suggestion needs a semicolon after the kzalloc
and (__user void *) on the kcalloc cast.

cheers, Joe

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ