dm: Use rcu_dereference() for accessing rcu pointer
authorPranith Kumar <bobby.prani@gmail.com>
Tue, 28 Oct 2014 22:09:56 +0000 (15:09 -0700)
committerMike Snitzer <snitzer@redhat.com>
Mon, 10 Nov 2014 20:25:29 +0000 (15:25 -0500)
The map field in 'struct mapped_device' is an rcu pointer. Use rcu_dereference()
while accessing it.

Signed-off-by: Pranith Kumar <bobby.prani@gmail.com>
Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
Signed-off-by: Mike Snitzer <snitzer@redhat.com>
drivers/md/dm.c

index 0fee0e54d36fa1685746268d9bab5df2d6c8436e..c5e14eee8c76a7a2a4201d095b3a89c552942183 100644 (file)
@@ -2332,7 +2332,7 @@ static struct dm_table *__bind(struct mapped_device *md, struct dm_table *t,
 
        merge_is_optional = dm_table_merge_is_optional(t);
 
-       old_map = md->map;
+       old_map = rcu_dereference(md->map);
        rcu_assign_pointer(md->map, t);
        md->immutable_target_type = dm_table_get_immutable_target_type(t);
 
@@ -2351,7 +2351,7 @@ static struct dm_table *__bind(struct mapped_device *md, struct dm_table *t,
  */
 static struct dm_table *__unbind(struct mapped_device *md)
 {
-       struct dm_table *map = md->map;
+       struct dm_table *map = rcu_dereference(md->map);
 
        if (!map)
                return NULL;
@@ -2745,7 +2745,7 @@ int dm_suspend(struct mapped_device *md, unsigned suspend_flags)
                goto out_unlock;
        }
 
-       map = md->map;
+       map = rcu_dereference(md->map);
 
        /*
         * DMF_NOFLUSH_SUSPENDING must be set before presuspend.
@@ -2839,7 +2839,7 @@ int dm_resume(struct mapped_device *md)
        if (!dm_suspended_md(md))
                goto out;
 
-       map = md->map;
+       map = rcu_dereference(md->map);
        if (!map || !dm_table_get_size(map))
                goto out;