]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
afs: Don't over-increment the cell usage count when pinning it
authorDavid Howells <dhowells@redhat.com>
Mon, 9 Apr 2018 20:12:31 +0000 (21:12 +0100)
committerDavid Howells <dhowells@redhat.com>
Mon, 9 Apr 2018 20:12:31 +0000 (21:12 +0100)
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 <dhowells@redhat.com>
fs/afs/cell.c
fs/afs/proc.c

index 69b95faacc5e1fbf9865a95420c799be6b5ab987..721425b98b31e8350b91d4b1d81d658bb6b57a45 100644 (file)
@@ -334,8 +334,8 @@ int afs_cell_init(struct afs_net *net, const char *rootcell)
                return PTR_ERR(new_root);
        }
 
-       set_bit(AFS_CELL_FL_NO_GC, &new_root->flags);
-       afs_get_cell(new_root);
+       if (!test_and_set_bit(AFS_CELL_FL_NO_GC, &new_root->flags))
+               afs_get_cell(new_root);
 
        /* install the new cell */
        write_seqlock(&net->cells_lock);
index 1c95756335b76adc285e46944f153e750ae693bf..2f04d37eeef04884918abb95e1d5be4e9f8145b3 100644 (file)
@@ -284,7 +284,8 @@ static ssize_t afs_proc_cells_write(struct file *file, const char __user *buf,
                        goto done;
                }
 
-               set_bit(AFS_CELL_FL_NO_GC, &cell->flags);
+               if (test_and_set_bit(AFS_CELL_FL_NO_GC, &cell->flags))
+                       afs_put_cell(net, cell);
                printk("kAFS: Added new cell '%s'\n", name);
        } else {
                goto inval;