summaryrefslogtreecommitdiff
path: root/libcutils/ashmem-dev.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'libcutils/ashmem-dev.cpp')
-rw-r--r--libcutils/ashmem-dev.cpp16
1 files changed, 10 insertions, 6 deletions
diff --git a/libcutils/ashmem-dev.cpp b/libcutils/ashmem-dev.cpp
index 8c232f0cd0..233d400e0e 100644
--- a/libcutils/ashmem-dev.cpp
+++ b/libcutils/ashmem-dev.cpp
@@ -122,7 +122,8 @@ static bool check_vendor_memfd_allowed() {
return true;
}
- /* If its not a number, assume string, but check if its a sane string */
+ // Non-numeric should be a single ASCII character. Characters after the
+ // first are ignored.
if (tolower(vndk_version[0]) < 'a' || tolower(vndk_version[0]) > 'z') {
ALOGE("memfd: ro.vndk.version not defined or invalid (%s), this is mandated since P.\n",
vndk_version.c_str());
@@ -211,13 +212,16 @@ static int __ashmem_open_locked()
// fallback for APEX w/ use_vendor on Q, which would have still used /dev/ashmem
if (fd < 0) {
+ int saved_errno = errno;
fd = TEMP_FAILURE_RETRY(open("/dev/ashmem", O_RDWR | O_CLOEXEC));
+ if (fd < 0) {
+ /* Q launching devices and newer must not reach here since they should have been
+ * able to open ashmem_device_path */
+ ALOGE("Unable to open ashmem device %s (error = %s) and /dev/ashmem(error = %s)",
+ ashmem_device_path.c_str(), strerror(saved_errno), strerror(errno));
+ return fd;
+ }
}
-
- if (fd < 0) {
- return fd;
- }
-
struct stat st;
int ret = TEMP_FAILURE_RETRY(fstat(fd, &st));
if (ret < 0) {