From: "Jun'ichi Nomura" Fix the bug in dm-raid1.c that the region returned by __rh_alloc() may be freed while it's in use. __rh_alloc() write-unlocks the hash_lock after inserting the new region. Though it read-locks the hash-lock just after that, it's possible that the region was reclaimed by rh_update_states() as the region was clean at the time. CPU0 CPU1 ----------------------------------------------------------------------- __rh_alloc() write_lock(hash_lock) write_unlock(hash_lock) rh_update_states() write_lock(hash_lock) write_unlock(hash_lock) read_lock(hash_lock) Signed-off-by: Jun'ichi Nomura Signed-off-by: Andrew Morton --- drivers/md/dm-raid1.c | 5 ++++- 1 files changed, 4 insertions(+), 1 deletion(-) [Upstream -mm] --- diff/drivers/md/dm-raid1.c 2005-06-29 18:10:52.000000000 +0100 +++ source/drivers/md/dm-raid1.c 2005-06-29 18:11:02.000000000 +0100 @@ -269,9 +269,12 @@ { struct region *reg; +retry: reg = __rh_lookup(rh, region); - if (!reg) + if (!reg) { reg = __rh_alloc(rh, region); + goto retry; + } return reg; }