On Tue, May 05, 2026 at 04:52:59PM +0800, Ren Wei wrote: > From: Yilin Zhu > > ipcomp_setup_req() allocates destination pages for the acomp output > scatterlist. On successful completion, ipcomp_post_acomp() attaches the > used pages to the skb and frees any unused pages. > > On an acomp error, ipcomp_post_acomp() skips directly to freeing the > request. acomp_request_free() only releases the request itself, so the > caller-allocated destination pages are left allocated. > > Track the number of destination pages allocated for the request and free > them on the error path before releasing the request. > > Fixes: eb2953d26971 ("xfrm: ipcomp: Use crypto_acomp interface") > Cc: stable@kernel.org > Reported-by: Yuan Tan > Reported-by: Yifan Wu > Reported-by: Juefei Pu > Reported-by: Xin Liu > Co-developed-by: Peihan Liu > Signed-off-by: Peihan Liu > Signed-off-by: Yilin Zhu > Signed-off-by: Ren Wei > --- > net/xfrm/xfrm_ipcomp.c | 16 +++++++++++++++- > 1 file changed, 15 insertions(+), 1 deletion(-) Thanks for the patch! How about just moving the out_free_req label: ---8<--- Move the out_free_req label up by a couple of lines so that the allocated dst SG list gets freed on error as well as success. Fixes: eb2953d26971 ("xfrm: ipcomp: Use crypto_acomp interface") Cc: stable@kernel.org Reported-by: Yuan Tan Reported-by: Yifan Wu Reported-by: Juefei Pu Reported-by: Xin Liu Signed-off-by: Herbert Xu diff --git a/net/xfrm/xfrm_ipcomp.c b/net/xfrm/xfrm_ipcomp.c index 5f38dff16177..2947321b043d 100644 --- a/net/xfrm/xfrm_ipcomp.c +++ b/net/xfrm/xfrm_ipcomp.c @@ -51,11 +51,12 @@ static int ipcomp_post_acomp(struct sk_buff *skb, int err, int hlen) struct scatterlist *dsg; int len, dlen; + extra = acomp_request_extra(req); + dsg = extra->sg; + if (unlikely(err)) goto out_free_req; - extra = acomp_request_extra(req); - dsg = extra->sg; dlen = req->dlen; pskb_trim_unique(skb, 0); @@ -84,10 +85,10 @@ static int ipcomp_post_acomp(struct sk_buff *skb, int err, int hlen) skb_shinfo(skb)->nr_frags++; } while ((dlen -= len)); +out_free_req: for (; dsg; dsg = sg_next(dsg)) __free_page(sg_page(dsg)); -out_free_req: acomp_request_free(req); return err; } -- Email: Herbert Xu Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt