Skip to content

Commit 17814ae

Browse files
committed
afs: Don't over-increment the cell usage count when pinning it
AFS cells that are added or set as the workstation cell through /proc are pinned against removal by setting the AFS_CELL_FL_NO_GC flag on them and taking a ref. The ref should be only taken if the flag wasn't already set. Fix this by making it conditional. Without this an assertion failure will occur during module removal indicating that the refcount is too elevated. Signed-off-by: David Howells <[email protected]>
1 parent fe342cf commit 17814ae

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

fs/afs/cell.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -334,8 +334,8 @@ int afs_cell_init(struct afs_net *net, const char *rootcell)
334334
return PTR_ERR(new_root);
335335
}
336336

337-
set_bit(AFS_CELL_FL_NO_GC, &new_root->flags);
338-
afs_get_cell(new_root);
337+
if (!test_and_set_bit(AFS_CELL_FL_NO_GC, &new_root->flags))
338+
afs_get_cell(new_root);
339339

340340
/* install the new cell */
341341
write_seqlock(&net->cells_lock);

fs/afs/proc.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,8 @@ static ssize_t afs_proc_cells_write(struct file *file, const char __user *buf,
284284
goto done;
285285
}
286286

287-
set_bit(AFS_CELL_FL_NO_GC, &cell->flags);
287+
if (test_and_set_bit(AFS_CELL_FL_NO_GC, &cell->flags))
288+
afs_put_cell(net, cell);
288289
printk("kAFS: Added new cell '%s'\n", name);
289290
} else {
290291
goto inval;

0 commit comments

Comments
 (0)