Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp245990ybl; Thu, 15 Aug 2019 16:34:54 -0700 (PDT) X-Google-Smtp-Source: APXvYqwaZrEFDWv3NVKM+nI9oxoxSXvCjD1o5JzNR5leJml1elHnETqs8pf8HbBrnjQDqO4/A8K7 X-Received: by 2002:a17:902:2f24:: with SMTP id s33mr6226697plb.314.1565912093945; Thu, 15 Aug 2019 16:34:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565912093; cv=none; d=google.com; s=arc-20160816; b=AmO2J2hQLud9TksawSA+Sa5RfdNJtpsmSWKeiFsPKmtODh5Knp4YxSfhg0+cbjmilj ny8tFeXQY2Y9VE9f+XoabyNf4wn0Qhxe4pcB1XBsGfSNrw337zexnte5t41RbGRuGj86 OxDwEbeDneNNRiwi50hAEjcm97IVLc4Q9VU6q+88gfrJcgLQVdIncnH/Q8YoBYOlGKJe dAi9OMHhgWORhA4deojwz7noeJ+C+DSyHhJkCGM6CO3aD2K5qXg64EWKiUioHrojAfXL cDPjcl7W55ronxnW5Eb9vSHQil2FCMZwltfE5b69D4oKToh4DSDGPJ0KJtEDBwUJ9WjG Brpw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature; bh=205QOW+yfCAbUC7sqLeSze+Vg1m2Bj7bh4Zpv9ddbPA=; b=ZpDo2JrYwku1vMzBEp4oOVQQEliaTpiZrpXUNYsIoGw+yooMOaefm3WVQHUiBDUaLX KqQwBMIsKMWfhQ/2vT9cdK6ginVcn7GlQMBhBWGMDh/aIg2B6j9waw1o+csNshqKfkaV QBE8OHzz8C7718bmkcU0c5MVlGcgT5Ou1KwPZfh2FGkOtJB/EcD6A7Ml8x9PfVDCM3e3 DJhdSBk2y2KFZjMCf0le3De6xgPAF4g4cAytEXTA/Rp2CirG0/xAqczpqHUHLLaD6KAl T4toyXjjKsKQRx/OOLZjO81c76+Bl+VzMNynGGY5uRZSBgIscToNUyteStMKdiVd43M0 U5fA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=aHSHLFL2; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z20si2800320plo.159.2019.08.15.16.34.38; Thu, 15 Aug 2019 16:34:53 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=aHSHLFL2; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732590AbfHOU4n (ORCPT + 99 others); Thu, 15 Aug 2019 16:56:43 -0400 Received: from mail-lj1-f196.google.com ([209.85.208.196]:35150 "EHLO mail-lj1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732521AbfHOU4m (ORCPT ); Thu, 15 Aug 2019 16:56:42 -0400 Received: by mail-lj1-f196.google.com with SMTP id l14so3425683lje.2 for ; Thu, 15 Aug 2019 13:56:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=205QOW+yfCAbUC7sqLeSze+Vg1m2Bj7bh4Zpv9ddbPA=; b=aHSHLFL2ibBV/js7b7q+6nct87exfpVR8oXwxPxV1O3q6wd5IOfaorpO5msfvRyevT nYKoDnt9kqYmiQu9PjsrPREPSVxpT9OzKTUoF3JQdooYysuqXafyRNzG7iDVEFoE0IeS 3ZoOHiiqJprJgUr8Tfrc/9AbsMPLPS0kBBA/XGerv/Vt/XOsD71F+/3fM9gEBNUCWZAk 65kZb29OLfGg5zb6VfW7gyr4F/F42sB/LPn1fUg0usLHPPnJzxH+vgNnMrCd32OsCh0f AsVZGyYS1Hp9/Ychz/oDWhBSoli78rvDYq7YI7yYJHv7gCl/+GTOkq96i3FHnuHbFrLk kNOg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=205QOW+yfCAbUC7sqLeSze+Vg1m2Bj7bh4Zpv9ddbPA=; b=YVPGAuqtHCY/1+HiwVM1FD66FXFHE5Y0bGEmuJKap0at1o4Ckpm4D+JLBwOY1P92EH y2JeCx+ejotSvPAKnU4cUFbPE9OiybVGJnDAy5ePKYJcEX+rL/iA6cO70r5eRr430t0j zkQeisXkpABycY80e9pUs442kQ5qQeG2Eig4hZlp9lGHRTPwkYlk9gJl4n96xy6jCg/B 43k3IYfuY3cK2v/qHH1tVu6nfPgiSQU6lefwVSIGAi+XW+tJqmDvHrRkhuWR3Bm5f/jH VrZpMPI1g+x8wsbUxK9zmC3TmlpHUle2tqk1sNYiZ7sYRvbxrWtQjoRQu4JpxLEZJRlr 0z+A== X-Gm-Message-State: APjAAAWgpocv5NBtILDovb1RIokqT2qokI2Ga7rA1DWw8J+P50AjbCT4 JIaD6gv7ars4Jvk1+f83Rb2wL3WGkgo= X-Received: by 2002:a2e:8510:: with SMTP id j16mr3721390lji.174.1565902600461; Thu, 15 Aug 2019 13:56:40 -0700 (PDT) Received: from localhost.localdomain (168-200-94-178.pool.ukrtel.net. [178.94.200.168]) by smtp.gmail.com with ESMTPSA id j14sm651676ljc.67.2019.08.15.13.56.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Aug 2019 13:56:39 -0700 (PDT) From: Ivan Khoronzhuk To: bjorn.topel@intel.com Cc: magnus.karlsson@intel.com, jonathan.lemon@gmail.com, davem@davemloft.net, ast@kernel.org, daniel@iogearbox.net, jakub.kicinski@netronome.com, hawk@kernel.org, john.fastabend@gmail.com, netdev@vger.kernel.org, bpf@vger.kernel.org, linux-kernel@vger.kernel.org, Ivan Khoronzhuk Subject: [PATCH bpf 1/1] xdp: unpin xdp umem pages in error path Date: Thu, 15 Aug 2019 23:56:35 +0300 Message-Id: <20190815205635.6536-1-ivan.khoronzhuk@linaro.org> X-Mailer: git-send-email 2.17.1 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Fix mem leak caused by missed unpin routine for umem pages. Fixes: 8aef7340ae9695 ("commit xsk: introduce xdp_umem_page") Signed-off-by: Ivan Khoronzhuk --- Based on bpf/master net/xdp/xdp_umem.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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; -- 2.17.1