From mboxrd@z Thu Jan 1 00:00:00 1970 From: Seth Howell Subject: [PATCH v3] eal/linuxapp: check mmap return value MAP_FAILED Date: Mon, 28 Aug 2017 14:49:12 -0700 Message-ID: <20170828214912.133503-1-seth.howell@intel.com> References: <20170815205336.9266-1-seth.howell@intel.com> Cc: Seth Howell To: dev@dpdk.org Return-path: Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by dpdk.org (Postfix) with ESMTP id AAE4811F5 for ; Mon, 28 Aug 2017 23:49:33 +0200 (CEST) In-Reply-To: <20170815205336.9266-1-seth.howell@intel.com> List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" If mmap fails, it will return the value MAP_FAILED. Checking for this return code allows us to properly identify mmap failures and report them as such to the calling function. Signed-off-by: Seth Howell --- lib/librte_eal/linuxapp/eal/eal_memory.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/librte_eal/linuxapp/eal/eal_memory.c b/lib/librte_eal/linuxapp/eal/eal_memory.c index 5279128..63fec29 100644 --- a/lib/librte_eal/linuxapp/eal/eal_memory.c +++ b/lib/librte_eal/linuxapp/eal/eal_memory.c @@ -716,6 +716,8 @@ create_shared_memory(const char *filename, const size_t mem_size) } retval = mmap(NULL, mem_size, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0); close(fd); + if (retval == MAP_FAILED) + return NULL; return retval; } -- 2.9.5