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]
Date:	Sat, 7 Jul 2007 15:36:24 +0200
From:	yoann padioleau <padator@...adoo.fr>
To:	Tilman Schmidt <tilman@...p.cc>
Cc:	kernel-janitors@...ts.osdl.org, akpm@...ux-foundation.org,
	linux-kernel@...r.kernel.org, Julia Lawall <julia@...u.dk>
Subject: Re: [PATCH] some kmalloc/memset ->kzalloc (tree wide)


On 7 juil. 07, at 15:07, Tilman Schmidt wrote:

> Am 06.07.2007 18:51 schrieb Yoann Padioleau:
>> @@
>> expression E1,E2,E3;
>> @@
>>
>> - kzalloc(E1 * E2,E3)
>> + kcalloc(E1,E2,E3)
>
> This misses the semantic distinction between the first and second
> arguments of kcalloc(). The first argument is supposed to be the
> number of elements to allocate and the second their size. As a
> consequence, the following hunks in your pathc are wrong:

Yes you are right. Andrew Morton fixed the problem in a
subsequent patch.

I should have written a more precise semantic patch such as

@@
expression E;
constant c;
type T;
@@

- kzalloc(sizeof(T) * c, E)
+ kcalloc(c, sizeof(T), E)


Note that sometimes the code is written as  kzalloc(c * sizeof(T), E)
as in   kzalloc(2 * sizeof(struct resource), GFP_KERNEL)  but
our transformation engine can handle the commutativity of '*' and still
performs the right transformation.


>
>> diff --git a/arch/arm/mach-iop13xx/pci.c b/arch/arm/mach-iop13xx/ 
>> pci.c
>> index 9d63d7f..b84955f 100644
>> --- a/arch/arm/mach-iop13xx/pci.c
>> +++ b/arch/arm/mach-iop13xx/pci.c
>> @@ -1002,11 +1002,10 @@ int iop13xx_pci_setup(int nr, struct pci
>>  	if (nr > 1)
>>  		return 0;
>>
>> -	res = kmalloc(sizeof(struct resource) * 2, GFP_KERNEL);
>> +	res = kcalloc(sizeof(struct resource), 2, GFP_KERNEL);
>>  	if (!res)
>>  		panic("PCI: unable to alloc resources");
>>
>> -	memset(res, 0, sizeof(struct resource) * 2);
>>
>>  	/* 'nr' assumptions:
>>  	 * ATUX is always 0
>


-
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