diff options
author | Sven Schnelle <svens@stackframe.org> | 2008-03-28 17:15:55 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2008-03-28 17:45:21 -0400 |
commit | 5214b729e1c2dc3af8f55e6c4c548844c3bea0f5 (patch) | |
tree | 8838edf8e3d4068c41816d7b17c63849318ceb93 | |
parent | fac533c2505b39faf30492cd3f0844c0da51c75c (diff) |
afs: prevent double cell registration
kafs doesn't check if the cell already exists - so if you do an echo "add
newcell.org 1.2.3.4" >/proc/fs/afs/cells it will try to create this cell
again. kobject will also complain about a double registration. To prevent
such problems, return -EEXIST in that case.
Signed-off-by: Sven Schnelle <svens@stackframe.org>
Signed-off-by: David Howells <dhowells@redhat.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-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 | /* |