diff --git a/include/linux/srcu.h b/include/linux/srcu.h index 8a45367b5f3a5f2f2fbd1bf3a4da3e5e1e6d575a..aca0eee53930f5014fc1037caab46d46cd16a855 100644 --- a/include/linux/srcu.h +++ b/include/linux/srcu.h @@ -43,7 +43,7 @@ struct srcu_struct { #define srcu_barrier() #endif /* #else #ifndef CONFIG_PREEMPT */ -void init_srcu_struct(struct srcu_struct *sp); +int init_srcu_struct(struct srcu_struct *sp); void cleanup_srcu_struct(struct srcu_struct *sp); int srcu_read_lock(struct srcu_struct *sp) __acquires(sp); void srcu_read_unlock(struct srcu_struct *sp, int idx) __releases(sp); diff --git a/kernel/srcu.c b/kernel/srcu.c index 7e1979f624ba57c904c706855c04fd64ed625b49..3507cabe963bd453857b68f6bf56b59103d0781d 100644 --- a/kernel/srcu.c +++ b/kernel/srcu.c @@ -42,11 +42,12 @@ * to any other function. Each srcu_struct represents a separate domain * of SRCU protection. */ -void init_srcu_struct(struct srcu_struct *sp) +int init_srcu_struct(struct srcu_struct *sp) { sp->completed = 0; - sp->per_cpu_ref = alloc_percpu(struct srcu_struct_array); mutex_init(&sp->mutex); + sp->per_cpu_ref = alloc_percpu(struct srcu_struct_array); + return (sp->per_cpu_ref ? 0 : -ENOMEM); } /* diff --git a/kernel/sys.c b/kernel/sys.c index fd5c710067754ffba439ef1252162e3a357c2d8b..98489d82801be030cb3477589ed952291e19eb7e 100644 --- a/kernel/sys.c +++ b/kernel/sys.c @@ -517,7 +517,8 @@ EXPORT_SYMBOL_GPL(srcu_notifier_call_chain); void srcu_init_notifier_head(struct srcu_notifier_head *nh) { mutex_init(&nh->mutex); - init_srcu_struct(&nh->srcu); + if (init_srcu_struct(&nh->srcu) < 0) + BUG(); nh->head = NULL; }