Skip to content

Commit 8a04d2f

Browse files
Labnannklassert
authored andcommitted
xfrm: Update ipcomp_scratches with NULL when freed
Currently if ipcomp_alloc_scratches() fails to allocate memory ipcomp_scratches holds obsolete address. So when we try to free the percpu scratches using ipcomp_free_scratches() it tries to vfree non existent vm area. Described below: static void * __percpu *ipcomp_alloc_scratches(void) { ... scratches = alloc_percpu(void *); if (!scratches) return NULL; ipcomp_scratches does not know about this allocation failure. Therefore holding the old obsolete address. ... } So when we free, static void ipcomp_free_scratches(void) { ... scratches = ipcomp_scratches; Assigning obsolete address from ipcomp_scratches if (!scratches) return; for_each_possible_cpu(i) vfree(*per_cpu_ptr(scratches, i)); Trying to free non existent page, causing warning: trying to vfree existent vm area. ... } Fix this breakage by updating ipcomp_scrtches with NULL when scratches is freed Suggested-by: Herbert Xu <[email protected]> Reported-by: [email protected] Tested-by: [email protected] Signed-off-by: Khalid Masum <[email protected]> Acked-by: Herbert Xu <[email protected]> Signed-off-by: Steffen Klassert <[email protected]>
1 parent 26dbd66 commit 8a04d2f

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

net/xfrm/xfrm_ipcomp.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,7 @@ static void ipcomp_free_scratches(void)
203203
vfree(*per_cpu_ptr(scratches, i));
204204

205205
free_percpu(scratches);
206+
ipcomp_scratches = NULL;
206207
}
207208

208209
static void * __percpu *ipcomp_alloc_scratches(void)

0 commit comments

Comments
 (0)