Skip to contentSkip to conversation

percpu_ref: don't refer to ref->data if it isn't allocated

PATCH In review Ming Lei 3 participants 3 messages Oct 9, 2020

Subsystems (3)
lore
Share & tools
lore

Ming Lei

author
#0 lore raw

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")
---
 lib/percpu-refcount.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
lib/percpu-refcount.c +1 -1
index b6350d13538a..e59eda07305e 100644
@@ -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
#1 lore raw
Quoted 5 lines · Ming Lei

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")

Please don't forget:

Reported-by [email protected]
maintainer
#2 lore raw
In reply to Ming Lei
Quoted 2 lines · Ming Lei

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.

Added with reported-by.

Signature · 1 line
Jens Axboe