percpu_ref: don't refer to ref->data if it isn't allocated
Subsystems (3)
PATCH 1/1 percpu_ref: don't refer to ref->data if it isn't allocated
We can't check ref->data->confirm_switch directly in __percpu_ref_exit(), since ref->data may not be allocated in one not-initialized refcount.
Fixes 2b0d3d3e4fcf ("percpu_ref: reduce memory footprint of percpu_ref in fast path")
Signed-off-by Ming Lei <[email protected]>
--- lib/percpu-refcount.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
lib/percpu-refcount.c +1 -1
@@ -109,7 +109,7 @@ static void __percpu_ref_exit(struct percpu_ref *ref)if (percpu_count) {/* non-NULL confirm_switch indicates switching in progress */ -WARN_ON_ONCE (ref->data->confirm_switch); +WARN_ON_ONCE (ref->data && ref->data->confirm_switch);free_percpu (percpu_count); ref->percpu_count_ptr = __PERCPU_REF_ATOMIC_DEAD; }
Signature · 1 line
2.25.2
Quoted 5 lines · Ming Lei
We can't check
ref->data->confirm_switchdirectly in__percpu_ref_exit(), sinceref->datamay not be allocated in one not-initialized refcount.Fixes 2b0d3d3e4fcf ("percpu_ref: reduce memory footprint of percpu_ref in fast path")Signed-off-by Ming Lei <[email protected]>
Please don't forget:
Reported-by [email protected]
Jens Axboe
maintainerQuoted 2 lines · Ming Lei
We can't check
ref->data->confirm_switchdirectly in__percpu_ref_exit(), sinceref->datamay not be allocated in one not-initialized refcount.
Added with reported-by.
Signature · 1 line
Jens Axboe