Skip to content

Commit

Permalink
xdp: unpin xdp umem pages in error path
Browse files Browse the repository at this point in the history
Fix mem leak caused by missed unpin routine for umem pages.

Fixes: 8aef734 ("xsk: introduce xdp_umem_page")
Signed-off-by: Ivan Khoronzhuk <ivan.khoronzhuk@linaro.org>
Acked-by: Jonathan Lemon <jonathan.lemon@gmail.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
  • Loading branch information
Ivan Khoronzhuk authored and Daniel Borkmann committed Aug 20, 2019
1 parent d34b044 commit fb89c39
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion net/xdp/xdp_umem.c
Original file line number Diff line number Diff line change
Expand Up @@ -365,14 +365,16 @@ static int xdp_umem_reg(struct xdp_umem *umem, struct xdp_umem_reg *mr)
umem->pages = kcalloc(umem->npgs, sizeof(*umem->pages), GFP_KERNEL);
if (!umem->pages) {
err = -ENOMEM;
goto out_account;
goto out_pin;
}

for (i = 0; i < umem->npgs; i++)
umem->pages[i].addr = page_address(umem->pgs[i]);

return 0;

out_pin:
xdp_umem_unpin_pages(umem);
out_account:
xdp_umem_unaccount_pages(umem);
return err;
Expand Down

0 comments on commit fb89c39

Please sign in to comment.