Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

afs: Use kfree_rcu() instead of casting kfree() to rcu_callback_t

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 <jannh@google.com>
Signed-off-by: David Howells <dhowells@redhat.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by

Jann Horn and committed by
Linus Torvalds
ddd2b85f 0d81a3f2

+2 -2
+1 -1
fs/afs/addr_list.c
··· 19 19 void afs_put_addrlist(struct afs_addr_list *alist) 20 20 { 21 21 if (alist && refcount_dec_and_test(&alist->usage)) 22 - call_rcu(&alist->rcu, (rcu_callback_t)kfree); 22 + kfree_rcu(alist, rcu); 23 23 } 24 24 25 25 /*
+1 -1
fs/afs/internal.h
··· 81 81 * List of server addresses. 82 82 */ 83 83 struct afs_addr_list { 84 - struct rcu_head rcu; /* Must be first */ 84 + struct rcu_head rcu; 85 85 refcount_t usage; 86 86 u32 version; /* Version */ 87 87 unsigned char max_addrs;