From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by dpdk.org (Postfix) with ESMTP id F35B67D1E for ; Tue, 15 Aug 2017 22:53:41 +0200 (CEST) Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 15 Aug 2017 13:53:40 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.41,379,1498546800"; d="scan'208";a="137887497" Received: from sethhowe-desk.ch.intel.com ([143.182.137.63]) by orsmga005.jf.intel.com with ESMTP; 15 Aug 2017 13:53:40 -0700 From: Seth Howell To: dev@dpdk.org Cc: Seth Howell Date: Tue, 15 Aug 2017 13:53:36 -0700 Message-Id: <20170815205336.9266-1-seth.howell@intel.com> X-Mailer: git-send-email 2.9.5 Subject: [dpdk-dev] [PATCH] eal/linuxapp: check mmap return value MAP_FAILED 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: , X-List-Received-Date: Tue, 15 Aug 2017 20:53:42 -0000 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..ba76b02 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