mirror of
https://git.kernel.org/pub/scm/bluetooth/bluez.git
synced 2024-11-26 13:44:23 +08:00
Include checks for mmap() returning NULL
This commit is contained in:
parent
118f08c948
commit
db17652952
@ -149,7 +149,7 @@ int textfile_put(char *pathname, char *key, char *value)
|
||||
}
|
||||
|
||||
map = mmap(NULL, size, PROT_READ | PROT_WRITE, MAP_SHARED | MAP_LOCKED, fd, 0);
|
||||
if (map == MAP_FAILED) {
|
||||
if (!map || map == MAP_FAILED) {
|
||||
err = errno;
|
||||
goto unlock;
|
||||
}
|
||||
@ -243,7 +243,7 @@ char *textfile_get(char *pathname, char *key)
|
||||
size = st.st_size;
|
||||
|
||||
map = mmap(NULL, size, PROT_READ, MAP_SHARED, fd, 0);
|
||||
if (map == MAP_FAILED) {
|
||||
if (!map || map == MAP_FAILED) {
|
||||
err = errno;
|
||||
goto unlock;
|
||||
}
|
||||
|
@ -2697,7 +2697,7 @@ int psr_read(const char *filename)
|
||||
}
|
||||
|
||||
map = mmap(0, st.st_size, PROT_READ, MAP_SHARED, fd, 0);
|
||||
if (map == MAP_FAILED) {
|
||||
if (!map || map == MAP_FAILED) {
|
||||
err = -errno;
|
||||
goto close;
|
||||
}
|
||||
|
@ -65,7 +65,7 @@ char *ouitocomp(const char *oui)
|
||||
memset(str, 0, 128);
|
||||
|
||||
map = mmap(0, st.st_size, PROT_READ, MAP_SHARED, fd, 0);
|
||||
if (map == MAP_FAILED) {
|
||||
if (!map || map == MAP_FAILED) {
|
||||
free(str);
|
||||
close(fd);
|
||||
return NULL;
|
||||
|
Loading…
Reference in New Issue
Block a user