RE: [Bug fix PATCH] resource: Reusing a resource structureallocated by bootmem

From: Wang, Rui Y
Date: Tue Apr 16 2013 - 04:17:23 EST


> -----Original Message-----
> From: Yasuaki Ishimatsu <isimatu.yasuaki@xxxxxxxxxxxxxx>
> Date: Mon, 15 Apr 2013 11:15:28 +0900
> Subject: [Bug fix PATCH] resource: Reusing a resource structure allocated by
> bootmem
> To: akpm@xxxxxxxxxxxxxxxxxxxx
> Cc: linux-kernel@xxxxxxxxxxxxxxx, rientjes@xxxxxxxxxx, linuxram@xxxxxxxxxx,
> toshi.kani@xxxxxx, Yasuaki Ishimatsu <isimatu.yasuaki@xxxxxxxxxxxxxx>
> <<...>>
> + if (bootmem_resource.sibling) {
> + spin_lock(&bootmem_resource_lock);
> + res = bootmem_resource.sibling;
> + bootmem_resource.sibling = res->sibling;
> + spin_unlock(&bootmem_resource_lock);
> + memset(res, 0, sizeof(struct resource));
> + } else {
> + res = kzalloc(sizeof(struct resource), flags);
> + }

bootmem_resource_lock does not protect the if() statement from accessing bootmem_resource.sibling.

spin_lock(&bootmem_resource_lock);
if (bootmem_resource.sibling) {
...

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