diff options
author | Manfred Spraul <manfred@colorfullife.com> | 2008-12-01 22:14:02 +0100 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2008-12-02 04:55:25 +0100 |
commit | 6ff2d39b91aec3dcae951afa982059e3dd9b49dc (patch) | |
tree | 8d480975d95adf85f3a87dd478e36e4ac0b0edd0 /include | |
parent | DMA-API.txt: fix description of pci_map_sg/dma_map_sg scatterlists handling (diff) | |
download | linux-6ff2d39b91aec3dcae951afa982059e3dd9b49dc.tar.xz linux-6ff2d39b91aec3dcae951afa982059e3dd9b49dc.zip |
lib/idr.c: fix rcu related race with idr_find
2nd part of the fixes needed for
http://bugzilla.kernel.org/show_bug.cgi?id=11796.
When the idr tree is either grown or shrunk, then the update to the number
of layers and the top pointer were not atomic. This race caused crashes.
The attached patch fixes that by replicating the layers counter in each
layer, thus idr_find doesn't need idp->layers anymore.
Signed-off-by: Manfred Spraul <manfred@colorfullife.com>
Cc: Clement Calmels <cboulte@gmail.com>
Cc: Nadia Derbey <Nadia.Derbey@bull.net>
Cc: Pierre Peiffer <peifferp@gmail.com>
Cc: <stable@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'include')
-rw-r--r-- | include/linux/idr.h | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/include/linux/idr.h b/include/linux/idr.h index fa035f96f2a3..dd846df8cd32 100644 --- a/include/linux/idr.h +++ b/include/linux/idr.h @@ -52,13 +52,14 @@ struct idr_layer { unsigned long bitmap; /* A zero bit means "space here" */ struct idr_layer *ary[1<<IDR_BITS]; int count; /* When zero, we can release it */ + int layer; /* distance from leaf */ struct rcu_head rcu_head; }; struct idr { struct idr_layer *top; struct idr_layer *id_free; - int layers; + int layers; /* only valid without concurrent changes */ int id_free_cnt; spinlock_t lock; }; |