]> git.baikalelectronics.ru Git - kernel.git/commit
srcu: Prevent cleanup_srcu_struct() from freeing non-dynamic ->sda
authorPaul E. McKenney <paulmck@kernel.org>
Thu, 27 Jan 2022 21:20:49 +0000 (13:20 -0800)
committerPaul E. McKenney <paulmck@kernel.org>
Mon, 11 Apr 2022 22:52:30 +0000 (15:52 -0700)
commit23f46e36b2fbd6e957625440a1a9fbfa67aad068
tree3f1adb38825845064a15ba7207f77ebda159db9b
parent81b13aa051d26977e7719bf09f7bcf99d0fc0aab
srcu: Prevent cleanup_srcu_struct() from freeing non-dynamic ->sda

When an srcu_struct structure is created (but not in a kernel module)
by DEFINE_SRCU() and friends, the per-CPU srcu_data structure is
statically allocated.  In all other cases, that structure is obtained
from alloc_percpu(), in which case cleanup_srcu_struct() must invoke
free_percpu() on the resulting ->sda pointer in the srcu_struct pointer.

Which it does.

Except that it also invokes free_percpu() on the ->sda pointer
referencing the statically allocated per-CPU srcu_data structures.
Which free_percpu() is surprisingly OK with.

This commit nevertheless stops cleanup_srcu_struct() from freeing
statically allocated per-CPU srcu_data structures.

Co-developed-by: Neeraj Upadhyay <quic_neeraju@quicinc.com>
Signed-off-by: Neeraj Upadhyay <quic_neeraju@quicinc.com>
Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
include/linux/srcutree.h
kernel/rcu/srcutree.c