From patchwork Tue Nov 6 21:48:57 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Hemminger X-Patchwork-Id: 47907 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 8905D493D; Tue, 6 Nov 2018 22:49:09 +0100 (CET) Received: from mail-pl1-f196.google.com (mail-pl1-f196.google.com [209.85.214.196]) by dpdk.org (Postfix) with ESMTP id 5BAFC239 for ; Tue, 6 Nov 2018 22:49:06 +0100 (CET) Received: by mail-pl1-f196.google.com with SMTP id f12-v6so5648983plo.1 for ; Tue, 06 Nov 2018 13:49:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=Yo+6M5Z8uTNoR+ZWOitlpbiBaJzQUeTIyPLNbkEnYnQ=; b=Wb66D7Nhizq0ivBxtjCoVt/Z5t5aky+uJNjEqQtbdKQ8WewiBk5NNqePpiKHu7A2Fm NhXq8sVyaY3oQ91XSCWdH2yWdzSdQesUGXvywrjtimt8ogRPKZVCzF8rsytDO/576Pxl puQ6HR/7VoEnrFTy0tWPVpd8UlgTMVyuwixV7B4NIGeKyUgrG/+Gm8trM8cRlZB4HcsS sKBeWzddhos6Cv2RLoJ6XeZFHRBefDoZC0RHJxCdFBX+Xcn8MxAcP8KOYL8E25hDrX4H 1cXHQISSaLHkmWe+x8ZGYDHE6lF10RSPtsPf1gyFjBOg2kkbtj2HqXllhJ4J5HnCIf6D Hh6w== 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:in-reply-to :references; bh=Yo+6M5Z8uTNoR+ZWOitlpbiBaJzQUeTIyPLNbkEnYnQ=; b=krMYHD+H9luJFRAyGRgBAkew2EjyU9/Uw88vvEt9HVVyrtm0oDyOojC0R/WnJ7G2VS HxVz3JqxUhjiCZlYH99W0aL8gdm6sDNtsmMcTdbNF46Ta2Lb8RpRFT86oE44XOAxOSaU l5LeE6n/8yOv2bF2rF2WGNJL+N76QtRkbh/1TKbDJs1CZl1Dj5aza5d/GBXkapYdnDWV /U0lBiou3IKGbpY1cOzqLNN2GNKrmIuiRnIWoXgWQO49T356EXsbjAmJp4cP3/fPh6Vq r5ybIErR0blO6hBIwwza8UmE711Tcvfp0EDL9wYYdXbE0sIensmYx755ZuLI08gE3cPk cgOA== X-Gm-Message-State: AGRZ1gJ2ZXERF4uoiOhB2upCMk8Z3GoqRVvrAquItYJE+HNwUTT3UJsL fBf8Ff5YuWLtL5gHVCezEK7j4WSghBs= X-Google-Smtp-Source: AJdET5dh2Te00BCGlMlOeQUiOm8NYqk7oOSQAPswqaOZsmdvHjOppK2j0YMyQCU3yQqGsBHIHZ1z2Q== X-Received: by 2002:a17:902:3103:: with SMTP id w3-v6mr28679796plb.51.1541540944875; Tue, 06 Nov 2018 13:49:04 -0800 (PST) Received: from localhost.localdomain ([167.220.103.1]) by smtp.gmail.com with ESMTPSA id y1sm5653608pfi.123.2018.11.06.13.49.04 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 06 Nov 2018 13:49:04 -0800 (PST) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger Date: Tue, 6 Nov 2018 13:48:57 -0800 Message-Id: <20181106214901.1392-2-stephen@networkplumber.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181106214901.1392-1-stephen@networkplumber.org> References: <20181106214901.1392-1-stephen@networkplumber.org> Subject: [dpdk-dev] [RFC 1/5] bus/pci: fix allocation of pci device path X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" The pci_resource_by_index called strlen() on uninitialized memory which would lead to the wrong size of memory allocated for the path portion of the resource map. This would either cause excessively large allocation, or worse memory corruption. Coverity Issue: 300868 Fixes: ea9d56226e72 ("pci: introduce function to map uio resource by index") Signed-off-by: Stephen Hemminger --- drivers/bus/pci/linux/pci_uio.c | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/drivers/bus/pci/linux/pci_uio.c b/drivers/bus/pci/linux/pci_uio.c index a7c14421aa79..112ac51dddcc 100644 --- a/drivers/bus/pci/linux/pci_uio.c +++ b/drivers/bus/pci/linux/pci_uio.c @@ -295,14 +295,6 @@ pci_uio_map_resource_by_index(struct rte_pci_device *dev, int res_idx, loc = &dev->addr; maps = uio_res->maps; - /* allocate memory to keep path */ - maps[map_idx].path = rte_malloc(NULL, strlen(devname) + 1, 0); - if (maps[map_idx].path == NULL) { - RTE_LOG(ERR, EAL, "Cannot allocate memory for path: %s\n", - strerror(errno)); - return -1; - } - /* * open resource file, to mmap it */ @@ -335,10 +327,19 @@ pci_uio_map_resource_by_index(struct rte_pci_device *dev, int res_idx, if (fd < 0) { RTE_LOG(ERR, EAL, "Cannot open %s: %s\n", devname, strerror(errno)); - goto error; + return -1; } } + /* allocate memory to keep path */ + maps[map_idx].path = rte_malloc(NULL, strlen(devname) + 1, 0); + if (maps[map_idx].path == NULL) { + RTE_LOG(ERR, EAL, "Cannot allocate memory for path: %s\n", + strerror(errno)); + close(fd); + return -1; + } + /* try mapping somewhere close to the end of hugepages */ if (pci_map_addr == NULL) pci_map_addr = pci_find_max_end_va(); @@ -346,8 +347,10 @@ pci_uio_map_resource_by_index(struct rte_pci_device *dev, int res_idx, mapaddr = pci_map_resource(pci_map_addr, fd, 0, (size_t)dev->mem_resource[res_idx].len, 0); close(fd); - if (mapaddr == MAP_FAILED) - goto error; + if (mapaddr == MAP_FAILED) { + rte_free(maps[map_idx].path); + return -1; + } pci_map_addr = RTE_PTR_ADD(mapaddr, (size_t)dev->mem_resource[res_idx].len); @@ -360,10 +363,6 @@ pci_uio_map_resource_by_index(struct rte_pci_device *dev, int res_idx, dev->mem_resource[res_idx].addr = mapaddr; return 0; - -error: - rte_free(maps[map_idx].path); - return -1; } #if defined(RTE_ARCH_X86) From patchwork Tue Nov 6 21:48:58 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Hemminger X-Patchwork-Id: 47908 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id A3DF74C92; Tue, 6 Nov 2018 22:49:11 +0100 (CET) Received: from mail-pg1-f194.google.com (mail-pg1-f194.google.com [209.85.215.194]) by dpdk.org (Postfix) with ESMTP id 1F6DB2D13 for ; Tue, 6 Nov 2018 22:49:07 +0100 (CET) Received: by mail-pg1-f194.google.com with SMTP id w7so6383635pgp.13 for ; Tue, 06 Nov 2018 13:49:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=iUaPNukdms8MJ8IZhKPNuUVYkfIXvL7pCCVfg+uj/A8=; b=uTx/Q5Kd2PANiMnnwIkDz5MXc5DEwxH5MVluY8tyiaripDHKynGRR0crsEpGYuSKPK gAQKK/8PhRrTe6cBVZCUZBmo6EYgRuwnJqjImzgBNFQhuNvkv6QS26z120wNNr6bEP7t 6fYJQkeaVOtR5R6Ol+PfQPmwCXhRa2UUYLwfArIkEfRfrdwTFjr6QJTvmAqe1BXmRMIF ttFN7CVCojJP9A3Zw4Kzo6IoPyF95l9D3bs3coNvVIYGDkqGgW0tYhbppUVQGnhD6pvN /eLe+6RgXAeqbvCt1WMKIp7OZjZOZsmuDWG2RL7F45o7r20eMfQsK28pbZtXMH93825G zBEA== 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:in-reply-to :references; bh=iUaPNukdms8MJ8IZhKPNuUVYkfIXvL7pCCVfg+uj/A8=; b=c1srLrwYTPqInqoYcC1xR8IFJuqs8J9kq1ONbrjRIs4giDVMfS28WQG+wNSOc5aTrK V7LKC9IJfgRHEmInpHqoR60oYhdUrKy6iYq8vEWtREUIpFnxHDc1TZA/sZIbYNGGQNvt Tl6Xb6XZ4jfW9B3XIqoRjdcxOlAOu8SdNgccADVPEBTAZhJdLSS7fRWOPrr7YnMxwlN5 oIoaQjr4i8cbgIGXAQooaenh7foF5FlF8Mo7qqCL9B5o/nPnHT+7MbMy9Se4EyD2XAl6 R9Wvg1HvQOAlHbBPhn07OICgSXYOBVtSDv+nXFb9VnFV6r3CpIkTcrZwpAyc+ZDGt3qE pZIg== X-Gm-Message-State: AGRZ1gI7hP2MeDI2yhpngQifs63v81QlnH79Uypok4zVP2xmVsWjCqJF QLqxnQ7QY+/7ZHDgTCxPqkFjeVsJPpM= X-Google-Smtp-Source: AJdET5dEL2Ok7QfkGL6uU5RAa6Ywg4oI41hDKzB5FgGLN8eU6XRpy9Eb/xnbSNwze696caN+wl2enA== X-Received: by 2002:a63:3c44:: with SMTP id i4mr25024510pgn.286.1541540945701; Tue, 06 Nov 2018 13:49:05 -0800 (PST) Received: from localhost.localdomain ([167.220.103.1]) by smtp.gmail.com with ESMTPSA id y1sm5653608pfi.123.2018.11.06.13.49.04 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 06 Nov 2018 13:49:05 -0800 (PST) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger Date: Tue, 6 Nov 2018 13:48:58 -0800 Message-Id: <20181106214901.1392-3-stephen@networkplumber.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181106214901.1392-1-stephen@networkplumber.org> References: <20181106214901.1392-1-stephen@networkplumber.org> Subject: [dpdk-dev] [RFC 2/5] bus/pci: fix TOCTOU issue X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Using access followed by open causes a static analysis warning about Time of check versus Time of use. Also, access() and open() have different UID permission checks. This is not a serious problem; but easy to fix by using errno instead. Coverity issue: 300870 Fixes: 4a928ef9f611 ("bus/pci: enable write combining during mapping") Signed-off-by: Stephen Hemminger --- drivers/bus/pci/linux/pci_uio.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/drivers/bus/pci/linux/pci_uio.c b/drivers/bus/pci/linux/pci_uio.c index 112ac51dddcc..8521fe63b0ae 100644 --- a/drivers/bus/pci/linux/pci_uio.c +++ b/drivers/bus/pci/linux/pci_uio.c @@ -306,12 +306,11 @@ pci_uio_map_resource_by_index(struct rte_pci_device *dev, int res_idx, loc->domain, loc->bus, loc->devid, loc->function, res_idx); - if (access(devname, R_OK|W_OK) != -1) { - fd = open(devname, O_RDWR); - if (fd < 0) - RTE_LOG(INFO, EAL, "%s cannot be mapped. " - "Fall-back to non prefetchable mode.\n", - devname); + fd = open(devname, O_RDWR); + if (fd < 0 && errno != ENOENT) { + RTE_LOG(INFO, EAL, "%s cannot be mapped. " + "Fall-back to non prefetchable mode.\n", + devname); } } From patchwork Tue Nov 6 21:48:59 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Hemminger X-Patchwork-Id: 47909 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 6EAE34CA2; Tue, 6 Nov 2018 22:49:13 +0100 (CET) Received: from mail-pf1-f194.google.com (mail-pf1-f194.google.com [209.85.210.194]) by dpdk.org (Postfix) with ESMTP id D826A2D13 for ; Tue, 6 Nov 2018 22:49:07 +0100 (CET) Received: by mail-pf1-f194.google.com with SMTP id g7-v6so4457727pfo.10 for ; Tue, 06 Nov 2018 13:49:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=k6p04W93CGSpfxLr2Gw0HqaUyg6z59j0zKr60x3ljbA=; b=M0dP98vOChtQaFFKR1LyWyXHNArgv6+sZQqzufFV3qEUWRo1IHtpg9QpIOF+gqijtd ryYwdTXn+tseA3mV1XMOFbGL58w77PNVZ2HPSh6iOd6OxaBn2ENszwPVf1UQjNv+DcZC mAjHMc9bfcUMvJSfOpkrr4exjIquNlXy26BlInIlZha1RJJM5OiFXC4tvoggA19mZDpG RfuYxohN1earrGD51B81vc97ZUPBSGC6RMKN1MLh7kz1HtglB7QSVX6BUU1th9AfKXDp O+IewWGMDAbk0WCzz64SDgCOOPyuu6fQkXwvrJADfv6o9a5wwK9MhUhK/U4tS+MHp9g2 X6Bw== 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:in-reply-to :references; bh=k6p04W93CGSpfxLr2Gw0HqaUyg6z59j0zKr60x3ljbA=; b=pwNXmYvAWu16EaptJ3XOJmLn9D2uvR32XGv04efxRVEn0AD3itc1N5reBYz60KayO5 1WYuS0y/VUVFyLkfIZtK1Uypbal8RH/H0JwPWZu0SCPa/8pVbGpMmFzoKkbuTpKt22Hb jr4tw9xr7FLW0eAJjjlni0itFdz3l/BAXEGgclFH+7oThT3HoHqvz4B343NPEgXvwFZs hIUhE6caFLfqKi6XF7BDZ21fD7Emf9DfiINqCl9kmXUXD7EbWfPMoxgw7GLo9m5QA4w8 QpGJg15zLcZcAW/yUpAAgqH0k5OZaLhcISap6gd3YeFq7ECtJsq1/zA8RXin13rbBmv6 j0kQ== X-Gm-Message-State: AGRZ1gLvHg5mrxCOHQKRv8JCP001dfkgrGwwYllpYO4I1QnkgHBvt6Yp 3Jcq4R5nlV8ZXToW+Uc4yZqPu3NMWGU= X-Google-Smtp-Source: AJdET5eIJ7Hpzuv1i9sgjrtJrZBVzaER7x/qmHEgGEn4P8kWoyIaZ3ZZXmgKJ3lmYck/5LPWuDw4dw== X-Received: by 2002:a63:8e43:: with SMTP id k64mr25030722pge.346.1541540946510; Tue, 06 Nov 2018 13:49:06 -0800 (PST) Received: from localhost.localdomain ([167.220.103.1]) by smtp.gmail.com with ESMTPSA id y1sm5653608pfi.123.2018.11.06.13.49.05 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 06 Nov 2018 13:49:05 -0800 (PST) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger Date: Tue, 6 Nov 2018 13:48:59 -0800 Message-Id: <20181106214901.1392-4-stephen@networkplumber.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181106214901.1392-1-stephen@networkplumber.org> References: <20181106214901.1392-1-stephen@networkplumber.org> Subject: [dpdk-dev] [RFC 3/5] bpf: fix validation of eal_divmod X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Coverity spotted self assignment in BPF eval_divmod. This looks like a bug where the incoming source register should have been used instead. Coverity issue: 302850 Fixes: 8021917293d0 ("bpf: add extra validation for input BPF program") Signed-off-by: Stephen Hemminger --- lib/librte_bpf/bpf_validate.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/librte_bpf/bpf_validate.c b/lib/librte_bpf/bpf_validate.c index 83983efc4e5c..b768f72c4c02 100644 --- a/lib/librte_bpf/bpf_validate.c +++ b/lib/librte_bpf/bpf_validate.c @@ -512,7 +512,7 @@ eval_divmod(uint32_t op, struct bpf_reg_val *rd, struct bpf_reg_val *rs, if (op == BPF_MOD) rd->u.max = RTE_MIN(rd->u.max, rs->u.max - 1); else - rd->u.max = rd->u.max; + rd->u.max = rs->u.max; rd->u.min = 0; } From patchwork Tue Nov 6 21:49:00 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Hemminger X-Patchwork-Id: 47910 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 5A6FA4F91; Tue, 6 Nov 2018 22:49:15 +0100 (CET) Received: from mail-pl1-f196.google.com (mail-pl1-f196.google.com [209.85.214.196]) by dpdk.org (Postfix) with ESMTP id 9B1A131FC for ; Tue, 6 Nov 2018 22:49:08 +0100 (CET) Received: by mail-pl1-f196.google.com with SMTP id p6-v6so6829509pll.4 for ; Tue, 06 Nov 2018 13:49:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=LrF2QpZBWl61wAdEzVTvopVPOQsXeHpnnpeEgQEx8i8=; b=HRjwC/MnUVlvqAB5yyGt/z+QouWsc0SaNjFyrlPklNFsCjpp9nCVDVkllMfy0CAhsF xGfdefxGsApBw+5J2eFuqdfYYOLo3iQEc/v896FdkV6YY9puwQNQO9yQ/xrh9O3ekn4Y GIncGitUHDPNOOxTdFROXEN4yU3UfrI4jslQpnGrE2K0bwJY6+X6QPAutki5OFt274mo LQcKmzUHkIxLpSvC6wYCJiPbx/QUtW/E5SOtQxPLkl0d3VwJr00GzqDi4eihfzJfBPWv SkqtP4AQ+oHD6wYt+T4Fvg3JUxHSjvil+nN2yqPJCWGxK/Kb3p16Lh0lomrd77aISOMM tWNw== 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:in-reply-to :references; bh=LrF2QpZBWl61wAdEzVTvopVPOQsXeHpnnpeEgQEx8i8=; b=d5/aX+NUyu3NBH0i6jXbFhEkU8iKvHRtpmpbCxtbVHiR5P0kYmzhGfR9cbHLYQ/sD9 u7M5YDx7lAq1C0ABhKz5eBp4cjVH4aaQ2YDCelXNeFZcCsTHQhNEpiHhy2Z9bw40oZtg iZ6JCol0d6zvmFmpTYPObEvN/FkaXkzK+3urxla+N3n0SCZqTNwI/6S+tv4w71s2sDkW 2dIDuEQrumCq2yvFno0uP8lgEl4Xt1E+zIyOZy1RE0MgBow7zPTxxLbOnpETfI9R71Mg 1mmVw3kFcW10j8ai888zG7OnwdaDrZnP9V/vuCgHofFvWly28drEYju6nr4pH04/O4FC 9ljw== X-Gm-Message-State: AGRZ1gLgqGKOsQ298ypgcG23dpsKdpcMBk/WrpPSDHxnCUViOP1qy4vK KoXsb/F0DTYl09C1N7A4erYztR5rmnU= X-Google-Smtp-Source: AJdET5dHDcBHP7IMQ8pFWa1fwf+yo0JJWJXkcHGe0AaOMVQBGpuxbIINU4mQPepfBq/QZ9QOsGefCA== X-Received: by 2002:a17:902:7c94:: with SMTP id y20-v6mr27948742pll.218.1541540947273; Tue, 06 Nov 2018 13:49:07 -0800 (PST) Received: from localhost.localdomain ([167.220.103.1]) by smtp.gmail.com with ESMTPSA id y1sm5653608pfi.123.2018.11.06.13.49.06 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 06 Nov 2018 13:49:06 -0800 (PST) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger Date: Tue, 6 Nov 2018 13:49:00 -0800 Message-Id: <20181106214901.1392-5-stephen@networkplumber.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181106214901.1392-1-stephen@networkplumber.org> References: <20181106214901.1392-1-stephen@networkplumber.org> Subject: [dpdk-dev] [RFC 4/5] eal/memory: avoid double munmap in error path X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Don't call munmap of hugepage memory twice in the error path. Coverity issue: 325730 Fixes: 66cc45e293ed ("mem: replace memseg with memseg lists") Signed-off-by: Stephen Hemminger --- lib/librte_eal/linuxapp/eal/eal_memory.c | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/librte_eal/linuxapp/eal/eal_memory.c b/lib/librte_eal/linuxapp/eal/eal_memory.c index c1b5e079117a..48b23ce19ad3 100644 --- a/lib/librte_eal/linuxapp/eal/eal_memory.c +++ b/lib/librte_eal/linuxapp/eal/eal_memory.c @@ -1617,6 +1617,7 @@ eal_legacy_hugepage_init(void) tmp_hp = NULL; munmap(hugepage, nr_hugefiles * sizeof(struct hugepage_file)); + hugepage = NULL; /* we're not going to allocate more pages, so release VA space for * unused memseg lists From patchwork Tue Nov 6 21:49:01 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Hemminger X-Patchwork-Id: 47911 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id B83875398; Tue, 6 Nov 2018 22:49:17 +0100 (CET) Received: from mail-pf1-f182.google.com (mail-pf1-f182.google.com [209.85.210.182]) by dpdk.org (Postfix) with ESMTP id 59B6331FC for ; Tue, 6 Nov 2018 22:49:09 +0100 (CET) Received: by mail-pf1-f182.google.com with SMTP id g7-v6so4457750pfo.10 for ; Tue, 06 Nov 2018 13:49:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=TvR3dD9trvfJtGoc8qyQLZswwsJGPWvtSoMGsZUEn0c=; b=J3MP5yaIMqkJAWtM6XDvDfVKiskrbHgfA9eDI9CkxTUNdX0qDe7HC8OleJ8Mu43FLN R8QHRqpQYw2WaguQYB/07s6DnFPpcgeStxKi2GqhmRfZytFcaGu4LIkDk5FW86f4c5w6 KrY1esTDHWQfa5Sjg0nHbAbjLIqIX4OiMJyFjpG+1VaE4jHV54bGkL4HVqTnaH00C4nm 80q9XINTVS+8uAFnuy8T8JU/qtxhPZUfECUtRHSMJtuTIul7ENFR6Uay+e/DihIoRadd 9kaGRkEiZn9dIAvAVCBq68RYL+fxRCGBGBpgEBjT9NZ8GRtmIdNt0m0QbuTVG09he5Ko JJqQ== 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:in-reply-to :references; bh=TvR3dD9trvfJtGoc8qyQLZswwsJGPWvtSoMGsZUEn0c=; b=MAw/h6/JJBipGNT+mGWsEnfjNuyYCcF6Ducpd9gWU9/iddPMG9vDqBIuQHbCj3UQBa HXZB/KQ64o7s0DEdokJQhzzo1jsIQyvA0WLg8J9xVMfTCJJuoZvejxRLnmH+dPk1krwG aDKJxaFzpN1S4o/FKzTjdI3/Bpy+ad+JZKCWoYd8grms8bMvtOi8yv6mOrO1/0t/cngM fTDGknc9rfVtRKok26PmTJO7iJAjayioPYDrL0tih/9v0X8obU7y+F33YExnARx4GHJH RqQ9aO2KdnE8NEp5BkiTR++YErLRy3tuR+OsRcORbdGqU6bM5XG+JGHM99g1A2UZib5/ R6og== X-Gm-Message-State: AGRZ1gL+Qa2J0kcwkkaj9NONQO/JfhIHtBN0q2XB7UtOuZ9g03Ty1vmR E76UfjXwK0GpsOhk6VAJhSWn8VRmmxY= X-Google-Smtp-Source: AJdET5d+elwsQ8g3/wTXI5INA1fCkXwYxCj6vX/tec/qpAWRaaM85nNhjW7xjSPJSbyuIpiPerOVYg== X-Received: by 2002:a63:5f41:: with SMTP id t62mr25361081pgb.76.1541540948182; Tue, 06 Nov 2018 13:49:08 -0800 (PST) Received: from localhost.localdomain ([167.220.103.1]) by smtp.gmail.com with ESMTPSA id y1sm5653608pfi.123.2018.11.06.13.49.07 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 06 Nov 2018 13:49:07 -0800 (PST) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger Date: Tue, 6 Nov 2018 13:49:01 -0800 Message-Id: <20181106214901.1392-6-stephen@networkplumber.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181106214901.1392-1-stephen@networkplumber.org> References: <20181106214901.1392-1-stephen@networkplumber.org> Subject: [dpdk-dev] [RFC 5/5] pipeline: remove dead code X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Coverity detected dead code since pointer into a global array can never be NULL. Coverity issue: 323523 Fixes: 96303217a606 ("pipeline: add symmetric crypto table action") Signed-off-by: Stephen Hemminger --- lib/librte_pipeline/rte_table_action.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/lib/librte_pipeline/rte_table_action.c b/lib/librte_pipeline/rte_table_action.c index 537e6593e4a0..69ab41a7ab2d 100644 --- a/lib/librte_pipeline/rte_table_action.c +++ b/lib/librte_pipeline/rte_table_action.c @@ -1696,8 +1696,6 @@ get_block_size(const struct rte_crypto_sym_xform *xform, uint8_t cdev_id) for (i = 0;; i++) { cap = &dev_info.capabilities[i]; - if (!cap) - break; if (cap->sym.xform_type != xform->type) continue;