@@ -1110,6 +1110,24 @@ static void pipapo_map(struct nft_pipapo_match *m,
11101110 f -> mt [map [i ].to + j ].e = e ;
11111111}
11121112
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+
11131131/**
11141132 * pipapo_realloc_scratch() - Reallocate scratch maps for partial match results
11151133 * @clone: Copy of matching data with pending insertions and deletions
@@ -1142,7 +1160,7 @@ static int pipapo_realloc_scratch(struct nft_pipapo_match *clone,
11421160 return - ENOMEM ;
11431161 }
11441162
1145- kfree ( * per_cpu_ptr ( clone -> scratch , i ) );
1163+ pipapo_free_scratch ( clone , i );
11461164
11471165 * per_cpu_ptr (clone -> scratch , i ) = scratch ;
11481166
@@ -1369,7 +1387,7 @@ static struct nft_pipapo_match *pipapo_clone(struct nft_pipapo_match *old)
13691387 }
13701388out_scratch_realloc :
13711389 for_each_possible_cpu (i )
1372- kfree ( * per_cpu_ptr ( new -> scratch , i ) );
1390+ pipapo_free_scratch ( new , i );
13731391#ifdef NFT_PIPAPO_ALIGN
13741392 free_percpu (new -> scratch_aligned );
13751393#endif
@@ -1653,7 +1671,7 @@ static void pipapo_free_match(struct nft_pipapo_match *m)
16531671 int i ;
16541672
16551673 for_each_possible_cpu (i )
1656- kfree ( * per_cpu_ptr ( m -> scratch , i ) );
1674+ pipapo_free_scratch ( m , i );
16571675
16581676#ifdef NFT_PIPAPO_ALIGN
16591677 free_percpu (m -> scratch_aligned );
@@ -2253,7 +2271,7 @@ static void nft_pipapo_destroy(const struct nft_ctx *ctx,
22532271 free_percpu (m -> scratch_aligned );
22542272#endif
22552273 for_each_possible_cpu (cpu )
2256- kfree ( * per_cpu_ptr ( m -> scratch , cpu ) );
2274+ pipapo_free_scratch ( m , cpu );
22572275 free_percpu (m -> scratch );
22582276 pipapo_free_fields (m );
22592277 kfree (m );
@@ -2270,7 +2288,7 @@ static void nft_pipapo_destroy(const struct nft_ctx *ctx,
22702288 free_percpu (priv -> clone -> scratch_aligned );
22712289#endif
22722290 for_each_possible_cpu (cpu )
2273- kfree ( * per_cpu_ptr ( priv -> clone -> scratch , cpu ) );
2291+ pipapo_free_scratch ( priv -> clone , cpu );
22742292 free_percpu (priv -> clone -> scratch );
22752293
22762294 pipapo_free_fields (priv -> clone );
0 commit comments