aboutsummaryrefslogtreecommitdiffstats
path: root/fs/afs/cell.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/afs/cell.c')
-rw-r--r--fs/afs/cell.c16
1 files changed, 14 insertions, 2 deletions
diff --git a/fs/afs/cell.c b/fs/afs/cell.c
index 970d38f30565..584bb0f9c36a 100644
--- a/fs/afs/cell.c
+++ b/fs/afs/cell.c
@@ -127,14 +127,21 @@ struct afs_cell *afs_cell_create(const char *name, char *vllist)
127 127
128 _enter("%s,%s", name, vllist); 128 _enter("%s,%s", name, vllist);
129 129
130 down_write(&afs_cells_sem);
131 read_lock(&afs_cells_lock);
132 list_for_each_entry(cell, &afs_cells, link) {
133 if (strcasecmp(cell->name, name) == 0)
134 goto duplicate_name;
135 }
136 read_unlock(&afs_cells_lock);
137
130 cell = afs_cell_alloc(name, vllist); 138 cell = afs_cell_alloc(name, vllist);
131 if (IS_ERR(cell)) { 139 if (IS_ERR(cell)) {
132 _leave(" = %ld", PTR_ERR(cell)); 140 _leave(" = %ld", PTR_ERR(cell));
141 up_write(&afs_cells_sem);
133 return cell; 142 return cell;
134 } 143 }
135 144
136 down_write(&afs_cells_sem);
137
138 /* add a proc directory for this cell */ 145 /* add a proc directory for this cell */
139 ret = afs_proc_cell_setup(cell); 146 ret = afs_proc_cell_setup(cell);
140 if (ret < 0) 147 if (ret < 0)
@@ -167,6 +174,11 @@ error:
167 kfree(cell); 174 kfree(cell);
168 _leave(" = %d", ret); 175 _leave(" = %d", ret);
169 return ERR_PTR(ret); 176 return ERR_PTR(ret);
177
178duplicate_name:
179 read_unlock(&afs_cells_lock);
180 up_write(&afs_cells_sem);
181 return ERR_PTR(-EEXIST);
170} 182}
171 183
172/* 184/*