Skip to contentSkip to conversation

eal/linuxapp: check mmap return value MAP_FAILED

PATCH Superseded Seth Howell 3 participants 5 messages Aug 15, 2017 – Oct 9, 2017

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 eal/linuxapp: check mmap return value MAP_FAILED

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.

---
 lib/librte_eal/linuxapp/eal/eal_memory.c | 2 ++
 1 file changed, 2 insertions(+)
lib/librte_eal/linuxapp/eal/eal_memory.c +2 -0
index 5279128..ba76b02 100644
@@ -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;
 }
 
Signature · 1 line
2.9.5
#1 lore raw

PATCH v2 1/1 eal/linuxapp: check mmap return value MAP_FAILED

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.

---
 lib/librte_eal/linuxapp/eal/eal_memory.c | 2 ++
 1 file changed, 2 insertions(+)
lib/librte_eal/linuxapp/eal/eal_memory.c +2 -0
index 5279128..ba76b02 100644
@@ -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;
 }
 
Signature · 1 line
2.9.5
#2 lore raw

PATCH v3 1/1 eal/linuxapp: check mmap return value MAP_FAILED

In reply to Seth Howell

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.

---
 lib/librte_eal/linuxapp/eal/eal_memory.c | 2 ++
 1 file changed, 2 insertions(+)
lib/librte_eal/linuxapp/eal/eal_memory.c +2 -0
index 5279128..63fec29 100644
@@ -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;
 }
 
Signature · 1 line
2.9.5
Acked-by on v3 1/1
#3 lore raw
Quoted 14 lines · Seth Howell

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.

---
  lib/librte_eal/linuxapp/eal/eal_memory.c | 2 ++
  1 file changed, 2 insertions(+)
lib/librte_eal/linuxapp/eal/eal_memory.c +0 -0
index 5279128..63fec29 100644

lib/librte_eal/linuxapp/eal/eal_memory.c create_shared_memory(const char *filename, const size_t mem_size) · line 723

Quoted 8 lines
lib/librte_eal/linuxapp/eal/eal_memory.c +2 -0
@@ -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;
  }