diff options
| author | 2016-01-27 19:04:53 +0000 | |
|---|---|---|
| committer | 2016-01-27 19:04:53 +0000 | |
| commit | cf9944684f438a1c3a47ab16c3efa4fa5d57f921 (patch) | |
| tree | b0bbd21d79e29ab2aec643d6216b60720a3d52a0 /libs/binder/Parcel.cpp | |
| parent | acca0abaf15318a6a260addd78566383bd4110a5 (diff) | |
| parent | eab2afc7ac5183750a23693ecee89dad7f7abf5f (diff) | |
Merge "system_server BINDER_TYPE_FD sockets using ashmem accessors"
Diffstat (limited to 'libs/binder/Parcel.cpp')
| -rw-r--r-- | libs/binder/Parcel.cpp | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/libs/binder/Parcel.cpp b/libs/binder/Parcel.cpp index 9ca3c06b15..3acd86955b 100644 --- a/libs/binder/Parcel.cpp +++ b/libs/binder/Parcel.cpp @@ -23,6 +23,9 @@ #include <stdio.h> #include <stdlib.h> #include <sys/mman.h> +#include <sys/stat.h> +#include <sys/types.h> +#include <unistd.h> #include <binder/Binder.h> #include <binder/BpBinder.h> @@ -120,8 +123,10 @@ void acquire_object(const sp<ProcessState>& proc, return; } case BINDER_TYPE_FD: { - if (obj.cookie != 0) { - if (outAshmemSize != NULL) { + if ((obj.cookie != 0) && (outAshmemSize != NULL)) { + struct stat st; + int ret = fstat(obj.handle, &st); + if (!ret && S_ISCHR(st.st_mode)) { // If we own an ashmem fd, keep track of how much memory it refers to. int size = ashmem_get_size_region(obj.handle); if (size > 0) { @@ -172,9 +177,13 @@ static void release_object(const sp<ProcessState>& proc, case BINDER_TYPE_FD: { if (obj.cookie != 0) { // owned if (outAshmemSize != NULL) { - int size = ashmem_get_size_region(obj.handle); - if (size > 0) { - *outAshmemSize -= size; + struct stat st; + int ret = fstat(obj.handle, &st); + if (!ret && S_ISCHR(st.st_mode)) { + int size = ashmem_get_size_region(obj.handle); + if (size > 0) { + *outAshmemSize -= size; + } } } |