Skip to content

Commit

Permalink
Judge mmap failed by MAP_FAILED instead of NULL
Browse files Browse the repository at this point in the history
Change-Id: I74422cfdba341fcd1a6235044700cf3986e853d0
Signed-off-by: Hurri Lu <jlu32@marvell.com>
  • Loading branch information
Hurri Lu committed May 22, 2014
1 parent 08c08f7 commit 473a729
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion fastbootd/transport.c
Expand Up @@ -55,7 +55,7 @@ int transport_handle_download(struct transport_handle *thandle, size_t len)
ftruncate(fd, len);

buffer = mmap(NULL, len, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
if (buffer == NULL) {
if (buffer == MAP_FAILED) {
D(ERR, "mmap(%zu) failed: %d %s", len, errno, strerror(errno));
goto err;
}
Expand Down
2 changes: 1 addition & 1 deletion libpixelflinger/codeflinger/CodeCache.cpp
Expand Up @@ -89,7 +89,7 @@ static mspace getMspace()
gExecutableStore = mmap(NULL, kMaxCodeCacheCapacity,
PROT_READ | PROT_WRITE | PROT_EXEC,
MAP_PRIVATE, fd, 0);
LOG_ALWAYS_FATAL_IF(gExecutableStore == NULL,
LOG_ALWAYS_FATAL_IF(gExecutableStore == MAP_FAILED,
"Creating code cache, mmap failed with error "
"'%s'", strerror(errno));
close(fd);
Expand Down

0 comments on commit 473a729

Please sign in to comment.