{"id":814911,"url":"http://patchwork.ozlabs.org/api/1.2/patches/814911/?format=json","web_url":"http://patchwork.ozlabs.org/project/netdev/patch/20170918130346.10833-1-tklauser@distanz.ch/","project":{"id":7,"url":"http://patchwork.ozlabs.org/api/1.2/projects/7/?format=json","name":"Linux network development","link_name":"netdev","list_id":"netdev.vger.kernel.org","list_email":"netdev@vger.kernel.org","web_url":null,"scm_url":null,"webscm_url":null,"list_archive_url":"","list_archive_url_format":"","commit_url_format":""},"msgid":"<20170918130346.10833-1-tklauser@distanz.ch>","list_archive_url":null,"date":"2017-09-18T13:03:46","name":"bpf: devmap: pass on return value of bpf_map_precharge_memlock","commit_ref":null,"pull_url":null,"state":"accepted","archived":true,"hash":"14def5d6848862ee7b60b4c826048ac42b6ef835","submitter":{"id":2451,"url":"http://patchwork.ozlabs.org/api/1.2/people/2451/?format=json","name":"Tobias Klauser","email":"tklauser@distanz.ch"},"delegate":{"id":34,"url":"http://patchwork.ozlabs.org/api/1.2/users/34/?format=json","username":"davem","first_name":"David","last_name":"Miller","email":"davem@davemloft.net"},"mbox":"http://patchwork.ozlabs.org/project/netdev/patch/20170918130346.10833-1-tklauser@distanz.ch/mbox/","series":[{"id":3641,"url":"http://patchwork.ozlabs.org/api/1.2/series/3641/?format=json","web_url":"http://patchwork.ozlabs.org/project/netdev/list/?series=3641","date":"2017-09-18T13:03:46","name":"bpf: devmap: pass on return value of bpf_map_precharge_memlock","version":1,"mbox":"http://patchwork.ozlabs.org/series/3641/mbox/"}],"comments":"http://patchwork.ozlabs.org/api/patches/814911/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/814911/checks/","tags":{},"related":[],"headers":{"Return-Path":"<netdev-owner@vger.kernel.org>","X-Original-To":"patchwork-incoming@ozlabs.org","Delivered-To":"patchwork-incoming@ozlabs.org","Authentication-Results":"ozlabs.org;\n\tspf=none (mailfrom) smtp.mailfrom=vger.kernel.org\n\t(client-ip=209.132.180.67; helo=vger.kernel.org;\n\tenvelope-from=netdev-owner@vger.kernel.org;\n\treceiver=<UNKNOWN>)","Received":["from vger.kernel.org (vger.kernel.org [209.132.180.67])\n\tby ozlabs.org (Postfix) with ESMTP id 3xwmRR4r7kz9s7M\n\tfor <patchwork-incoming@ozlabs.org>;\n\tMon, 18 Sep 2017 23:04:03 +1000 (AEST)","(majordomo@vger.kernel.org) by vger.kernel.org via listexpand\n\tid S1754622AbdIRNEC (ORCPT <rfc822;patchwork-incoming@ozlabs.org>);\n\tMon, 18 Sep 2017 09:04:02 -0400","from mail.zhinst.com ([212.126.164.98]:46754 \"EHLO mail.zhinst.com\"\n\trhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP\n\tid S1752112AbdIRNEB (ORCPT <rfc822;netdev@vger.kernel.org>);\n\tMon, 18 Sep 2017 09:04:01 -0400","from ziws08.zhinst.com ([10.42.0.7])\n\tby mail.zhinst.com (Kerio Connect 9.2.4) with ESMTP;\n\tMon, 18 Sep 2017 15:03:46 +0200"],"From":"Tobias Klauser <tklauser@distanz.ch>","To":"Alexei Starovoitov <ast@kernel.org>,\n\tDaniel Borkmann <daniel@iogearbox.net>","Cc":"John Fastabend <john.fastabend@gmail.com>, netdev@vger.kernel.org","Subject":"[PATCH] bpf: devmap: pass on return value of\n\tbpf_map_precharge_memlock","Date":"Mon, 18 Sep 2017 15:03:46 +0200","Message-Id":"<20170918130346.10833-1-tklauser@distanz.ch>","X-Mailer":"git-send-email 2.13.0","Sender":"netdev-owner@vger.kernel.org","Precedence":"bulk","List-ID":"<netdev.vger.kernel.org>","X-Mailing-List":"netdev@vger.kernel.org"},"content":"If bpf_map_precharge_memlock in dev_map_alloc, -ENOMEM is returned\nregardless of the actual error produced by bpf_map_precharge_memlock.\nFix it by passing on the error returned by bpf_map_precharge_memlock.\n\nAlso return -EINVAL instead of -ENOMEM if the page count overflow check\nfails.\n\nThis makes dev_map_alloc match the behavior of other bpf maps' alloc\nfunctions wrt. return values.\n\nSigned-off-by: Tobias Klauser <tklauser@distanz.ch>\n---\n kernel/bpf/devmap.c | 6 ++++--\n 1 file changed, 4 insertions(+), 2 deletions(-)","diff":"diff --git a/kernel/bpf/devmap.c b/kernel/bpf/devmap.c\nindex 959c9a07f318..e093d9a2c4dd 100644\n--- a/kernel/bpf/devmap.c\n+++ b/kernel/bpf/devmap.c\n@@ -75,8 +75,8 @@ static u64 dev_map_bitmap_size(const union bpf_attr *attr)\n static struct bpf_map *dev_map_alloc(union bpf_attr *attr)\n {\n \tstruct bpf_dtab *dtab;\n+\tint err = -EINVAL;\n \tu64 cost;\n-\tint err;\n \n \t/* check sanity of attributes */\n \tif (attr->max_entries == 0 || attr->key_size != 4 ||\n@@ -108,6 +108,8 @@ static struct bpf_map *dev_map_alloc(union bpf_attr *attr)\n \tif (err)\n \t\tgoto free_dtab;\n \n+\terr = -ENOMEM;\n+\n \t/* A per cpu bitfield with a bit per possible net device */\n \tdtab->flush_needed = __alloc_percpu(dev_map_bitmap_size(attr),\n \t\t\t\t\t    __alignof__(unsigned long));\n@@ -128,7 +130,7 @@ static struct bpf_map *dev_map_alloc(union bpf_attr *attr)\n free_dtab:\n \tfree_percpu(dtab->flush_needed);\n \tkfree(dtab);\n-\treturn ERR_PTR(-ENOMEM);\n+\treturn ERR_PTR(err);\n }\n \n static void dev_map_free(struct bpf_map *map)\n","prefixes":[]}