Skip to content

Commit

Permalink
afs: Fix afs_server_list to be cleaned up with RCU
Browse files Browse the repository at this point in the history
[ Upstream commit e6bace7 ]

afs_server_list is accessed with the rcu_read_lock() held from
volume->servers, so it needs to be cleaned up correctly.

Fix this by using kfree_rcu() instead of kfree().

Fixes: 8a070a9 ("afs: Detect cell aliases 1 - Cells with root volumes")
Signed-off-by: David Howells <dhowells@redhat.com>
cc: Marc Dionne <marc.dionne@auristor.com>
cc: linux-afs@lists.infradead.org
Signed-off-by: Sasha Levin <sashal@kernel.org>
  • Loading branch information
dhowells authored and gregkh committed Dec 3, 2023
1 parent 6ac30d7 commit 790ea5b
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
1 change: 1 addition & 0 deletions fs/afs/internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -552,6 +552,7 @@ struct afs_server_entry {
};

struct afs_server_list {
struct rcu_head rcu;
afs_volid_t vids[AFS_MAXTYPES]; /* Volume IDs */
refcount_t usage;
unsigned char nr_servers;
Expand Down
2 changes: 1 addition & 1 deletion fs/afs/server_list.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ void afs_put_serverlist(struct afs_net *net, struct afs_server_list *slist)
for (i = 0; i < slist->nr_servers; i++)
afs_unuse_server(net, slist->servers[i].server,
afs_server_trace_put_slist);
kfree(slist);
kfree_rcu(slist, rcu);
}
}

Expand Down

0 comments on commit 790ea5b

Please sign in to comment.