From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 54110A0A0C for ; Mon, 17 May 2021 18:21:56 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 4CAB4410F3; Mon, 17 May 2021 18:21:56 +0200 (CEST) Received: from youngberry.canonical.com (youngberry.canonical.com [91.189.89.112]) by mails.dpdk.org (Postfix) with ESMTP id A4DF140F35 for ; Mon, 17 May 2021 18:21:55 +0200 (CEST) Received: from 2.general.paelzer.uk.vpn ([10.172.196.173] helo=Keschdeichel.fritz.box) by youngberry.canonical.com with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.93) (envelope-from ) id 1lig09-0000R5-F8; Mon, 17 May 2021 16:21:53 +0000 From: Christian Ehrhardt To: Chengwen Feng Cc: Min Hu , Xiaoyun Li , dpdk stable Date: Mon, 17 May 2021 18:21:15 +0200 Message-Id: <20210517162125.3178901-11-christian.ehrhardt@canonical.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210517162125.3178901-1-christian.ehrhardt@canonical.com> References: <20210517162125.3178901-1-christian.ehrhardt@canonical.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-stable] patch 'raw/ntb: check memory allocations' has been queued to stable release 19.11.9 X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org Sender: "stable" Hi, FYI, your patch has been queued to stable release 19.11.9 Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet. It will be pushed if I get no objections before 05/19/21. So please shout if anyone has objections. Also note that after the patch there's a diff of the upstream commit vs the patch applied to the branch. This will indicate if there was any rebasing needed to apply to the stable branch. If there were code changes for rebasing (ie: not only metadata diffs), please double check that the rebase was correctly done. Queued patches are on a temporary branch at: https://github.com/cpaelzer/dpdk-stable-queue This queued commit can be viewed at: https://github.com/cpaelzer/dpdk-stable-queue/commit/3ebb07801c117f3807df26fccee4ac6c304c33a1 Thanks. Christian Ehrhardt --- >From 3ebb07801c117f3807df26fccee4ac6c304c33a1 Mon Sep 17 00:00:00 2001 From: Chengwen Feng Date: Wed, 21 Apr 2021 10:08:16 +0800 Subject: [PATCH] raw/ntb: check memory allocations [ upstream commit 403f21feb87fc9e0e2f61c1e4576cc1b9300ed4b ] This patch adds checking for rte_zmalloc() result when init Intel ntb device, also fix the same bug when start ntb device. Fixes: 034c328eb025 ("raw/ntb: support Intel NTB") Fixes: c39d1e082a4b ("raw/ntb: setup queues") Signed-off-by: Chengwen Feng Signed-off-by: Min Hu (Connor) Acked-by: Xiaoyun Li --- drivers/raw/ntb/ntb.c | 5 +++++ drivers/raw/ntb/ntb_hw_intel.c | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/drivers/raw/ntb/ntb.c b/drivers/raw/ntb/ntb.c index 6ac794037b..0f0f5c785c 100644 --- a/drivers/raw/ntb/ntb.c +++ b/drivers/raw/ntb/ntb.c @@ -894,6 +894,11 @@ ntb_dev_start(struct rte_rawdev *dev) hw->peer_mw_base = rte_zmalloc("ntb_peer_mw_base", hw->mw_cnt * sizeof(uint64_t), 0); + if (hw->peer_mw_base == NULL) { + NTB_LOG(ERR, "Cannot allocate memory for peer mw base."); + ret = -ENOMEM; + goto err_q_init; + } if (hw->ntb_ops->spad_read == NULL) { ret = -ENOTSUP; diff --git a/drivers/raw/ntb/ntb_hw_intel.c b/drivers/raw/ntb/ntb_hw_intel.c index e7f8667cd7..88fe6a3794 100644 --- a/drivers/raw/ntb/ntb_hw_intel.c +++ b/drivers/raw/ntb/ntb_hw_intel.c @@ -79,6 +79,11 @@ intel_ntb_dev_init(const struct rte_rawdev *dev) hw->mw_size = rte_zmalloc("ntb_mw_size", hw->mw_cnt * sizeof(uint64_t), 0); + if (hw->mw_size == NULL) { + NTB_LOG(ERR, "Cannot allocate memory for mw size."); + return -ENOMEM; + } + for (i = 0; i < hw->mw_cnt; i++) { bar = intel_ntb_bar[i]; hw->mw_size[i] = hw->pci_dev->mem_resource[bar].len; -- 2.31.1 --- Diff of the applied patch vs upstream commit (please double-check if non-empty: --- --- - 2021-05-17 17:40:37.198540556 +0200 +++ 0200-raw-ntb-check-memory-allocations.patch 2021-05-17 17:40:29.579812690 +0200 @@ -1 +1 @@ -From 403f21feb87fc9e0e2f61c1e4576cc1b9300ed4b Mon Sep 17 00:00:00 2001 +From 3ebb07801c117f3807df26fccee4ac6c304c33a1 Mon Sep 17 00:00:00 2001 @@ -5,0 +6,2 @@ +[ upstream commit 403f21feb87fc9e0e2f61c1e4576cc1b9300ed4b ] + @@ -11 +12,0 @@ -Cc: stable@dpdk.org @@ -22 +23 @@ -index 0f0e3f27a0..6703bb5d08 100644 +index 6ac794037b..0f0f5c785c 100644 @@ -25 +26 @@ -@@ -923,6 +923,11 @@ ntb_dev_start(struct rte_rawdev *dev) +@@ -894,6 +894,11 @@ ntb_dev_start(struct rte_rawdev *dev) @@ -38 +39 @@ -index 4427e11458..a742e8fbb9 100644 +index e7f8667cd7..88fe6a3794 100644 @@ -41 +42 @@ -@@ -148,6 +148,11 @@ intel_ntb_dev_init(const struct rte_rawdev *dev) +@@ -79,6 +79,11 @@ intel_ntb_dev_init(const struct rte_rawdev *dev)