From patchwork Mon Apr 19 13:34:40 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "humin (Q)" X-Patchwork-Id: 91762 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 49851A0524; Mon, 19 Apr 2021 15:35:40 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id AA5B54131E; Mon, 19 Apr 2021 15:35:01 +0200 (CEST) Received: from szxga05-in.huawei.com (szxga05-in.huawei.com [45.249.212.191]) by mails.dpdk.org (Postfix) with ESMTP id 01293412F4 for ; Mon, 19 Apr 2021 15:34:50 +0200 (CEST) Received: from DGGEMS411-HUB.china.huawei.com (unknown [172.30.72.59]) by szxga05-in.huawei.com (SkyGuard) with ESMTP id 4FP7623rNtzqTm9; Mon, 19 Apr 2021 21:32:26 +0800 (CST) Received: from localhost.localdomain (10.69.192.56) by DGGEMS411-HUB.china.huawei.com (10.3.19.211) with Microsoft SMTP Server id 14.3.498.0; Mon, 19 Apr 2021 21:34:37 +0800 From: "Min Hu (Connor)" To: CC: , , , , , , , , Date: Mon, 19 Apr 2021 21:34:40 +0800 Message-ID: <1618839289-33224-2-git-send-email-humin29@huawei.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1618839289-33224-1-git-send-email-humin29@huawei.com> References: <1618839289-33224-1-git-send-email-humin29@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.69.192.56] X-CFilter-Loop: Reflected Subject: [dpdk-dev] [PATCH 01/10] net/pfe: check return value X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 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" Variable 'fd', which may receive negative value when open "/dev/mem" file. This patch added checking return value process. Fixes: 67fc3ff97c39 ("net/pfe: introduce basic functions") Cc: stable@dpdk.org Signed-off-by: Min Hu (Connor) --- drivers/net/pfe/pfe_ethdev.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/net/pfe/pfe_ethdev.c b/drivers/net/pfe/pfe_ethdev.c index 8cf59e2..b4f5591 100644 --- a/drivers/net/pfe/pfe_ethdev.c +++ b/drivers/net/pfe/pfe_ethdev.c @@ -1049,6 +1049,12 @@ pmd_pfe_probe(struct rte_vdev_device *vdev) g_pfe->cbus_size = cbus_size; fd = open("/dev/mem", O_RDWR); + if (fd < 0) { + PFE_PMD_ERR("Can not open /dev/mem"); + rc = -EIO; + goto err; + } + g_pfe->cbus_baseaddr = mmap(NULL, cbus_size, PROT_READ | PROT_WRITE, MAP_SHARED, fd, cbus_addr); close(fd);