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] [thread-next>] [day] [month] [year] [list]
Message-ID: <44BD9BA8.7070202@cluded.net>
Date:	Wed, 19 Jul 2006 02:40:40 +0000
From:	"Daniel K." <daniel@...ded.net>
To:	Panagiotis Issaris <takis@...umba.uhasselt.be>
CC:	linux-kernel@...r.kernel.org, len.brown@...el.com,
	chas@....nrl.navy.mil, miquel@...uba.ar, kkeil@...e.de,
	benh@...nel.crashing.org, video4linux-list@...hat.com,
	rmk+mmc@....linux.org.uk, Neela.Kolli@...enio.com,
	jgarzik@...ox.com, vandrove@...cvut.cz, adaplas@....net,
	thomas@...ischhofer.net, weissg@...nna.at, philb@....org,
	linux-pcmcia@...ts.infradead.org, jkmaline@...hut.fi,
	paulus@...ba.org
Subject: Re: [PATCH] drivers: Conversions from kmalloc+memset to k(z|c)alloc.

Panagiotis Issaris wrote:
> diff --git a/drivers/char/rio/rio_linux.c b/drivers/char/rio/rio_linux.c
> index 3fa80aa..7c84863 100644
> --- a/drivers/char/rio/rio_linux.c
> +++ b/drivers/char/rio/rio_linux.c
> @@ -802,12 +802,7 @@ static int rio_init_drivers(void)
>  
>  static void *ckmalloc(int size)
>  {
> -	void *p;
> -
> -	p = kmalloc(size, GFP_KERNEL);
> -	if (p)
> -		memset(p, 0, size);
> -	return p;
> +	return kzalloc(size, GFP_KERNEL);
>  }
>  
>  
> diff --git a/drivers/char/rio/riocmd.c b/drivers/char/rio/riocmd.c
> index 4df6ab2..593940f 100644
> --- a/drivers/char/rio/riocmd.c
> +++ b/drivers/char/rio/riocmd.c
> @@ -556,9 +556,7 @@ struct CmdBlk *RIOGetCmdBlk(void)
>  {
>  	struct CmdBlk *CmdBlkP;
>  
> -	CmdBlkP = (struct CmdBlk *)kmalloc(sizeof(struct CmdBlk), GFP_ATOMIC);
> -	if (CmdBlkP)
> -		memset(CmdBlkP, 0, sizeof(struct CmdBlk));
> +	CmdBlkP = kzalloc(sizeof(struct CmdBlk), GFP_ATOMIC);
>  	return CmdBlkP;
>  }
>  

Why not return kzalloc(...) here? Alternatively, return (type *) kzalloc(...),
if you believe in explicit type casting of void pointers.

> diff --git a/drivers/serial/ip22zilog.c b/drivers/serial/ip22zilog.c
> index 5ff269f..ca0e9f2 100644
> --- a/drivers/serial/ip22zilog.c
> +++ b/drivers/serial/ip22zilog.c
> @@ -925,11 +925,7 @@ static int zilog_irq = -1;
>  static void * __init alloc_one_table(unsigned long size)
>  {
>  	void *ret;
> -
> -	ret = kmalloc(size, GFP_KERNEL);
> -	if (ret != NULL)
> -		memset(ret, 0, size);
> -
> +	ret = kzalloc(size, GFP_KERNEL);
>  	return ret;
>  }
>  

And here as well.

What is preferred by developers?


Daniel K.
-
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