*/
inode_unlock(dir);
error = securityfs_pin_fs();
- mutex_lock(&parent->lock);
inode_lock_nested(dir, I_MUTEX_PARENT);
if (error)
goto out;
if (error)
goto out_pin;
- ns = __aa_find_or_create_ns(parent, READ_ONCE(dentry->d_name.name),
- dentry);
+ ns = aa_create_ns(parent, ACCESS_ONCE(dentry->d_name.name), dentry);
if (IS_ERR(ns)) {
error = PTR_ERR(ns);
ns = NULL;
out_pin:
securityfs_release_fs();
out:
- mutex_unlock(&parent->lock);
aa_put_ns(parent);
return error;
struct aa_ns *aa_find_ns(struct aa_ns *root, const char *name);
struct aa_ns *aa_findn_ns(struct aa_ns *root, const char *name, size_t n);
-struct aa_ns *__aa_find_or_create_ns(struct aa_ns *parent, const char *name,
- struct dentry *dir);
+struct aa_ns *aa_create_ns(struct aa_ns *parent, const char *name,
+ struct dentry *dir);
struct aa_ns *aa_prepare_ns(struct aa_ns *root, const char *name);
void __aa_remove_ns(struct aa_ns *ns);
*
* Returns: the a refcounted ns that has been add or an ERR_PTR
*/
-struct aa_ns *__aa_find_or_create_ns(struct aa_ns *parent, const char *name,
- struct dentry *dir)
+struct aa_ns *aa_create_ns(struct aa_ns *parent, const char *name,
+ struct dentry *dir)
{
struct aa_ns *ns;
- AA_BUG(!mutex_is_locked(&parent->lock));
-
+ mutex_lock(&parent->lock);
/* try and find the specified ns */
/* released by caller */
ns = aa_get_ns(__aa_find_ns(&parent->sub_ns, name));
ns = __aa_create_ns(parent, name, dir);
else
ns = ERR_PTR(-EEXIST);
+ mutex_unlock(&parent->lock);
/* return ref */
return ns;