@@ -1110,6 +1110,24 @@ static void pipapo_map(struct nft_pipapo_match *m,
1110
1110
f -> mt [map [i ].to + j ].e = e ;
1111
1111
}
1112
1112
1113
+ /**
1114
+ * pipapo_free_scratch() - Free per-CPU map at original (not aligned) address
1115
+ * @m: Matching data
1116
+ * @cpu: CPU number
1117
+ */
1118
+ static void pipapo_free_scratch (const struct nft_pipapo_match * m , unsigned int cpu )
1119
+ {
1120
+ struct nft_pipapo_scratch * s ;
1121
+ void * mem ;
1122
+
1123
+ s = * per_cpu_ptr (m -> scratch , cpu );
1124
+ if (!s )
1125
+ return ;
1126
+
1127
+ mem = s ;
1128
+ kfree (mem );
1129
+ }
1130
+
1113
1131
/**
1114
1132
* pipapo_realloc_scratch() - Reallocate scratch maps for partial match results
1115
1133
* @clone: Copy of matching data with pending insertions and deletions
@@ -1142,7 +1160,7 @@ static int pipapo_realloc_scratch(struct nft_pipapo_match *clone,
1142
1160
return - ENOMEM ;
1143
1161
}
1144
1162
1145
- kfree ( * per_cpu_ptr ( clone -> scratch , i ) );
1163
+ pipapo_free_scratch ( clone , i );
1146
1164
1147
1165
* per_cpu_ptr (clone -> scratch , i ) = scratch ;
1148
1166
@@ -1369,7 +1387,7 @@ static struct nft_pipapo_match *pipapo_clone(struct nft_pipapo_match *old)
1369
1387
}
1370
1388
out_scratch_realloc :
1371
1389
for_each_possible_cpu (i )
1372
- kfree ( * per_cpu_ptr ( new -> scratch , i ) );
1390
+ pipapo_free_scratch ( new , i );
1373
1391
#ifdef NFT_PIPAPO_ALIGN
1374
1392
free_percpu (new -> scratch_aligned );
1375
1393
#endif
@@ -1653,7 +1671,7 @@ static void pipapo_free_match(struct nft_pipapo_match *m)
1653
1671
int i ;
1654
1672
1655
1673
for_each_possible_cpu (i )
1656
- kfree ( * per_cpu_ptr ( m -> scratch , i ) );
1674
+ pipapo_free_scratch ( m , i );
1657
1675
1658
1676
#ifdef NFT_PIPAPO_ALIGN
1659
1677
free_percpu (m -> scratch_aligned );
@@ -2253,7 +2271,7 @@ static void nft_pipapo_destroy(const struct nft_ctx *ctx,
2253
2271
free_percpu (m -> scratch_aligned );
2254
2272
#endif
2255
2273
for_each_possible_cpu (cpu )
2256
- kfree ( * per_cpu_ptr ( m -> scratch , cpu ) );
2274
+ pipapo_free_scratch ( m , cpu );
2257
2275
free_percpu (m -> scratch );
2258
2276
pipapo_free_fields (m );
2259
2277
kfree (m );
@@ -2270,7 +2288,7 @@ static void nft_pipapo_destroy(const struct nft_ctx *ctx,
2270
2288
free_percpu (priv -> clone -> scratch_aligned );
2271
2289
#endif
2272
2290
for_each_possible_cpu (cpu )
2273
- kfree ( * per_cpu_ptr ( priv -> clone -> scratch , cpu ) );
2291
+ pipapo_free_scratch ( priv -> clone , cpu );
2274
2292
free_percpu (priv -> clone -> scratch );
2275
2293
2276
2294
pipapo_free_fields (priv -> clone );
0 commit comments