File tree Expand file tree Collapse file tree 1 file changed +8
-2
lines changed Expand file tree Collapse file tree 1 file changed +8
-2
lines changed Original file line number Diff line number Diff line change @@ -201,14 +201,20 @@ def percpu_ref_sum(prog: Program, ref: Object) -> int:
201201 :param ref: ``struct percpu_ref``
202202 :returns: sum of the percpu reference count
203203 """
204- ptr = ref .percpu_count_ptr
205- atomic_count = ref .count if has_member (ref , "count" ) else ref .data .count
204+ if has_member (ref , "data" ):
205+ if ref .data .value_ () != 0 :
206+ atomic_count = ref .data .count
207+ else :
208+ return 0
209+ else :
210+ atomic_count = ref .count
206211 # Last two bits of ptr is uses as flags, not in percpu mode if any bit set.
207212 # PERCPU_COUNT_BIAS = (1LU << (BITS_PER_LONG - 1)) was set to counter
208213 # in percpu mode.
209214 bits_per_long = prog .type ("long" ).size * 8
210215 PERCPU_COUNT_BIAS = 1 << (bits_per_long - 1 )
211216 counter = atomic_count .counter & ~ PERCPU_COUNT_BIAS
217+ ptr = ref .percpu_count_ptr
212218 if ptr & 0x3 != 0 or ptr == 0 :
213219 return int (counter )
214220 percpu = Object (prog , "unsigned long" , address = ptr )
You can’t perform that action at this time.
0 commit comments