Commit 6022e75b authored by NeilBrown's avatar NeilBrown

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: default avatarNeilBrown <neilb@suse.com>
parent abb9b22a
...@@ -7427,15 +7427,19 @@ int unregister_md_personality(struct md_personality *p) ...@@ -7427,15 +7427,19 @@ int unregister_md_personality(struct md_personality *p)
} }
EXPORT_SYMBOL(unregister_md_personality); 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) int ret = 0;
return -EALREADY;
spin_lock(&pers_lock); spin_lock(&pers_lock);
md_cluster_ops = ops; if (md_cluster_ops != NULL)
md_cluster_mod = module; ret = -EALREADY;
else {
md_cluster_ops = ops;
md_cluster_mod = module;
}
spin_unlock(&pers_lock); spin_unlock(&pers_lock);
return 0; return ret;
} }
EXPORT_SYMBOL(register_md_cluster_operations); EXPORT_SYMBOL(register_md_cluster_operations);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment