summaryrefslogtreecommitdiff
path: root/ashmemd_client.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'ashmemd_client.cpp')
-rw-r--r--ashmemd_client.cpp5
1 files changed, 5 insertions, 0 deletions
diff --git a/ashmemd_client.cpp b/ashmemd_client.cpp
index 3380209..04227ba 100644
--- a/ashmemd_client.cpp
+++ b/ashmemd_client.cpp
@@ -28,6 +28,11 @@ namespace android {
namespace ashmemd {
sp<IAshmemDeviceService> getAshmemService() {
+ // Calls to defaultServiceManager() crash the process if it doesn't have appropriate
+ // binder permissions. Check these permissions proactively.
+ if (access("/dev/binder", R_OK | W_OK) != 0) {
+ return nullptr;
+ }
sp<IServiceManager> sm = android::defaultServiceManager();
sp<IBinder> binder = sm->checkService(String16("ashmem_device_service"));
return interface_cast<IAshmemDeviceService>(binder);