summaryrefslogtreecommitdiff
path: root/drivers/md/md.c
diff options
context:
space:
mode:
authorNeilBrown <neilb@suse.com>2015-08-13 02:32:55 (GMT)
committerNeilBrown <neilb@suse.com>2015-08-31 17:42:59 (GMT)
commit6022e75bf0686799a6ecca3c33a669e6c70e9d26 (patch)
treece4378e5017f76d1f8b48640eb13971001461923 /drivers/md/md.c
parentabb9b22ac948000ae156cd2d115c8632ec30a2ce (diff)
downloadlinux-6022e75bf0686799a6ecca3c33a669e6c70e9d26.tar.xz
md: extend spinlock protection in register_md_cluster_operations
This code looks racy. The only possible race is if two modules try to register at the same time and that won't happen. But make the code look safe anyway. Signed-off-by: NeilBrown <neilb@suse.com>
Diffstat (limited to 'drivers/md/md.c')
-rw-r--r--drivers/md/md.c16
1 files changed, 10 insertions, 6 deletions
diff --git a/drivers/md/md.c b/drivers/md/md.c
index c063760..7d5a6ced 100644
--- a/drivers/md/md.c
+++ b/drivers/md/md.c
@@ -7427,15 +7427,19 @@ int unregister_md_personality(struct md_personality *p)
}
EXPORT_SYMBOL(unregister_md_personality);
-int register_md_cluster_operations(struct md_cluster_operations *ops, struct module *module)
+int register_md_cluster_operations(struct md_cluster_operations *ops,
+ struct module *module)
{
- if (md_cluster_ops != NULL)
- return -EALREADY;
+ int ret = 0;
spin_lock(&pers_lock);
- md_cluster_ops = ops;
- md_cluster_mod = module;
+ if (md_cluster_ops != NULL)
+ ret = -EALREADY;
+ else {
+ md_cluster_ops = ops;
+ md_cluster_mod = module;
+ }
spin_unlock(&pers_lock);
- return 0;
+ return ret;
}
EXPORT_SYMBOL(register_md_cluster_operations);