Commit acc080d1 authored by David Howells's avatar David Howells

afs: Fix tracing deref-before-check

The patch dca54a7b: "afs: Add tracing for cell refcount and active user
count" from Oct 13, 2020, leads to the following Smatch complaint:

    fs/afs/cell.c:596 afs_unuse_cell()
    warn: variable dereferenced before check 'cell' (see line 592)

Fix this by moving the retrieval of the cell debug ID to after the check of
the validity of the cell pointer.
Reported-by: default avatarDan Carpenter <dan.carpenter@oracle.com>
Fixes: dca54a7b ("afs: Add tracing for cell refcount and active user count")
Signed-off-by: default avatarDavid Howells <dhowells@redhat.com>
cc: Dan Carpenter <dan.carpenter@oracle.com>
parent 06a17bbe
...@@ -589,7 +589,7 @@ struct afs_cell *afs_use_cell(struct afs_cell *cell, enum afs_cell_trace reason) ...@@ -589,7 +589,7 @@ struct afs_cell *afs_use_cell(struct afs_cell *cell, enum afs_cell_trace reason)
*/ */
void afs_unuse_cell(struct afs_net *net, struct afs_cell *cell, enum afs_cell_trace reason) void afs_unuse_cell(struct afs_net *net, struct afs_cell *cell, enum afs_cell_trace reason)
{ {
unsigned int debug_id = cell->debug_id; unsigned int debug_id;
time64_t now, expire_delay; time64_t now, expire_delay;
int u, a; int u, a;
...@@ -604,6 +604,7 @@ void afs_unuse_cell(struct afs_net *net, struct afs_cell *cell, enum afs_cell_tr ...@@ -604,6 +604,7 @@ void afs_unuse_cell(struct afs_net *net, struct afs_cell *cell, enum afs_cell_tr
if (cell->vl_servers->nr_servers) if (cell->vl_servers->nr_servers)
expire_delay = afs_cell_gc_delay; expire_delay = afs_cell_gc_delay;
debug_id = cell->debug_id;
u = atomic_read(&cell->ref); u = atomic_read(&cell->ref);
a = atomic_dec_return(&cell->active); a = atomic_dec_return(&cell->active);
trace_afs_cell(debug_id, u, a, reason); trace_afs_cell(debug_id, u, a, reason);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment