diff mbox series

[bpf,1/1] xdp: unpin xdp umem pages in error path

Message ID 20190815205635.6536-1-ivan.khoronzhuk@linaro.org
State New
Headers show
Series [bpf,1/1] xdp: unpin xdp umem pages in error path | expand

Commit Message

Ivan Khoronzhuk Aug. 15, 2019, 8:56 p.m. UTC
Fix mem leak caused by missed unpin routine for umem pages.
Fixes: 8aef7340ae9695 ("commit xsk: introduce xdp_umem_page")

Signed-off-by: Ivan Khoronzhuk <ivan.khoronzhuk@linaro.org>

---

Based on bpf/master

 net/xdp/xdp_umem.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

-- 
2.17.1

Comments

Jonathan Lemon Aug. 15, 2019, 9:01 p.m. UTC | #1
On 15 Aug 2019, at 13:56, Ivan Khoronzhuk wrote:

> Fix mem leak caused by missed unpin routine for umem pages.

> Fixes: 8aef7340ae9695 ("commit xsk: introduce xdp_umem_page")

>

> Signed-off-by: Ivan Khoronzhuk <ivan.khoronzhuk@linaro.org>


Acked-by: Jonathan Lemon <jonathan.lemon@gmail.com>
Daniel Borkmann Aug. 20, 2019, 3:12 p.m. UTC | #2
On 8/15/19 10:56 PM, Ivan Khoronzhuk wrote:
> Fix mem leak caused by missed unpin routine for umem pages.

> Fixes: 8aef7340ae9695 ("commit xsk: introduce xdp_umem_page")

> 

> Signed-off-by: Ivan Khoronzhuk <ivan.khoronzhuk@linaro.org>


Applied & fixed up 'Fixes:' tag, thanks.
diff mbox series

Patch

diff --git a/net/xdp/xdp_umem.c b/net/xdp/xdp_umem.c
index 83de74ca729a..688aac7a6943 100644
--- a/net/xdp/xdp_umem.c
+++ b/net/xdp/xdp_umem.c
@@ -365,7 +365,7 @@  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++)
@@ -373,6 +373,8 @@  static int xdp_umem_reg(struct xdp_umem *umem, struct xdp_umem_reg *mr)
 
 	return 0;
 
+out_pin:
+	xdp_umem_unpin_pages(umem);
 out_account:
 	xdp_umem_unaccount_pages(umem);
 	return err;