diff options
Diffstat (limited to 'fs/afs')
-rw-r--r-- | fs/afs/cell.c | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/fs/afs/cell.c b/fs/afs/cell.c index 970d38f30565..788865df1bc9 100644 --- a/fs/afs/cell.c +++ b/fs/afs/cell.c | |||
@@ -127,14 +127,20 @@ 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)); |
133 | return cell; | 141 | return cell; |
134 | } | 142 | } |
135 | 143 | ||
136 | down_write(&afs_cells_sem); | ||
137 | |||
138 | /* add a proc directory for this cell */ | 144 | /* add a proc directory for this cell */ |
139 | ret = afs_proc_cell_setup(cell); | 145 | ret = afs_proc_cell_setup(cell); |
140 | if (ret < 0) | 146 | if (ret < 0) |
@@ -167,6 +173,11 @@ error: | |||
167 | kfree(cell); | 173 | kfree(cell); |
168 | _leave(" = %d", ret); | 174 | _leave(" = %d", ret); |
169 | return ERR_PTR(ret); | 175 | return ERR_PTR(ret); |
176 | |||
177 | duplicate_name: | ||
178 | read_unlock(&afs_cells_lock); | ||
179 | up_write(&afs_cells_sem); | ||
180 | return ERR_PTR(-EEXIST); | ||
170 | } | 181 | } |
171 | 182 | ||
172 | /* | 183 | /* |