]> git.baikalelectronics.ru Git - kernel.git/commitdiff
afs: Use kfree_rcu() instead of casting kfree() to rcu_callback_t
authorJann Horn <jannh@google.com>
Thu, 12 Mar 2020 21:36:53 +0000 (21:36 +0000)
committerLinus Torvalds <torvalds@linux-foundation.org>
Fri, 13 Mar 2020 17:47:33 +0000 (10:47 -0700)
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>
fs/afs/addr_list.c
fs/afs/internal.h

index df415c05939e7ad4f5d7716d68e4f2bead7eecf7..de1ae0bead3baf9192bde373287924c3b0d500fd 100644 (file)
@@ -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);
 }
 
 /*
index 1d81fc4c3058c328fcbdbe960dafd1a553b26661..35f951ac296f47edbf04dbdd847270b61b757288 100644 (file)
@@ -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;