Skip to content

Commit

Permalink
afs: Use kfree_rcu() instead of casting kfree() to rcu_callback_t
Browse files Browse the repository at this point in the history
afs_put_addrlist() casts kfree() to rcu_callback_t. Apart from being wrong
in theory, this might also blow up when people start enforcing function
types via compiler instrumentation, and it means the rcu_head has to be
first in struct afs_addr_list.

Use kfree_rcu() instead, it's simpler and more correct.

Signed-off-by: Jann Horn <[email protected]>
Signed-off-by: David Howells <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
thejh authored and torvalds committed Mar 13, 2020
1 parent 0d81a3f commit ddd2b85
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion fs/afs/addr_list.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
void afs_put_addrlist(struct afs_addr_list *alist)
{
if (alist && refcount_dec_and_test(&alist->usage))
call_rcu(&alist->rcu, (rcu_callback_t)kfree);
kfree_rcu(alist, rcu);
}

/*
Expand Down
2 changes: 1 addition & 1 deletion fs/afs/internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ enum afs_call_state {
* List of server addresses.
*/
struct afs_addr_list {
struct rcu_head rcu; /* Must be first */
struct rcu_head rcu;
refcount_t usage;
u32 version; /* Version */
unsigned char max_addrs;
Expand Down

0 comments on commit ddd2b85

Please sign in to comment.