projects/linux·commit ddd2b85f

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

ddd2b85f · Jann Horn <[email protected]> · 2020-03-12 21:36:53 +00:00

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]>
Commit
ddd2b85ff73bb60061a9fb08ac1f5a03a2d4bce0
Parents
0d81a3f2

Changes

2 files changed · +2 −2

FileStatusAddDelContent
fs/afs/addr_list.cmodified+1−1View file
fs/afs/internal.hmodified+1−1View file

fs/afs/addr_list.c

View file
diff --git a/fs/afs/addr_list.c b/fs/afs/addr_list.c
index df415c0..de1ae0b 100644
--- a/fs/afs/addr_list.c
+++ b/fs/afs/addr_list.c
@@ -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);
}
/*

fs/afs/internal.h

View file
diff --git a/fs/afs/internal.h b/fs/afs/internal.h
index 1d81fc4..35f951a 100644
--- a/fs/afs/internal.h
+++ b/fs/afs/internal.h
@@ -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;