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:	Fri, 19 Apr 2013 08:43:55 +0900
From:	Yasuaki Ishimatsu <isimatu.yasuaki@...fujitsu.com>
To:	Toshi Kani <toshi.kani@...com>
CC:	<akpm@...ux-foundation.org>, <linuxram@...ibm.com>,
	<rientjes@...gle.com>, <linux-kernel@...r.kernel.org>,
	<linux-mm@...ck.org>
Subject: Re: [Bug fix PATCH v4] Reusing a resource structure allocated by
 bootmem

2013/04/19 8:28, Toshi Kani wrote:
> On Fri, 2013-04-19 at 08:33 +0900, Yasuaki Ishimatsu wrote:
>   :
>>>
>>>> +static struct resource *get_resource(gfp_t flags)
>>>> +{
>>>> +	struct resource *res = NULL;
>>>> +
>>>> +	spin_lock(&bootmem_resource_lock);
>>>> +	if (bootmem_resource.sibling) {
>>>> +		res = bootmem_resource.sibling;
>>>> +		bootmem_resource.sibling = res->sibling;
>>>> +		memset(res, 0, sizeof(struct resource));
>>>> +	}
>>>> +	spin_unlock(&bootmem_resource_lock);
>>>
>>
>>> I prefer to keep memset() outside of the spin lock.
>>>
>>> spin_lock(&bootmem_resource_lock);
>>> if (..) {
>>> 	:
>>> 	spin_unlock(&bootmem_resource_lock);
>>> 	memset(res, 0, sizeof(struct resource));
>>> } else {
>>> 	spin_unlock(&bootmem_resource_lock);
>>> 	res = kzalloc(sizeof(struct resource), flags);
>>> }
>>
>> Hmm. It is a little ugly. How about it?
>>
>> spin_lock(&bootmem_resource_lock);
>> if (bootmem_resource.sibling) {
>> 	res = bootmem_resource.sibling;
>> 	bootmem_resource.sibling = res->sibling;
>> }
>> spin_unlock(&bootmem_resource_lock);
>>
>> if (res)
>> 	memset(res, 0, sizeof(struct resource));
>> else	
>> 	res = kzalloc(sizeof(struct resource), flags);
>

> Sounds good to me.

Great. I'll update it.

Thanks,
Yasuaki Ishimatsu

>
> Thanks,
> -Toshi
>
>


--
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