From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by dpdk.org (Postfix) with ESMTP id 93F745B20; Fri, 1 Jun 2018 15:45:02 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga107.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 01 Jun 2018 06:45:00 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.49,467,1520924400"; d="scan'208";a="52675519" Received: from kraken.imu.intel.com (HELO Sent) ([10.217.246.153]) by fmsmga002.fm.intel.com with SMTP; 01 Jun 2018 06:44:58 -0700 Received: by Sent (sSMTP sendmail emulation); Fri, 01 Jun 2018 15:44:56 +0200 From: Dariusz Stojaczyk To: dev@dpdk.org, Anatoly Burakov Cc: Dariusz Stojaczyk , stable@dpdk.org Date: Fri, 1 Jun 2018 15:44:39 +0200 Message-Id: <1527860679-110206-1-git-send-email-dariuszx.stojaczyk@intel.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1527859375-160704-1-git-send-email-dariuszx.stojaczyk@intel.com> References: <1527859375-160704-1-git-send-email-dariuszx.stojaczyk@intel.com> Subject: [dpdk-stable] [PATCH v2] memory: fix segfault on rte_mem_virt2memseg() call with invalid addr X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 01 Jun 2018 13:45:03 -0000 When trying to use it with an address that's not managed by DPDK it would segfault due to a missing check. The doc says this function returns either a pointer or NULL, so let it do so. Changes from v1: * removed gerrit change id * added "git fixline" tags Fixes: 66cc45e293ed ("mem: replace memseg with memseg lists") Cc: anatoly.burakov@intel.com Cc: stable@dpdk.org Signed-off-by: Dariusz Stojaczyk --- lib/librte_eal/common/eal_common_memory.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/librte_eal/common/eal_common_memory.c b/lib/librte_eal/common/eal_common_memory.c index 4f0688f..ecc5bb2 100644 --- a/lib/librte_eal/common/eal_common_memory.c +++ b/lib/librte_eal/common/eal_common_memory.c @@ -536,6 +536,9 @@ virt2memseg(const void *addr, const struct rte_memseg_list *msl) void *start, *end; int ms_idx; + if (msl == NULL) + return NULL; + /* a memseg list was specified, check if it's the right one */ start = msl->base_va; end = RTE_PTR_ADD(start, (size_t)msl->page_sz * msl->memseg_arr.len); -- 2.7.4