From 9a147033f8f250050635a4fce36b36dd28b1df14 Mon Sep 17 00:00:00 2001 From: Hridya Valsaraju Date: Fri, 7 Aug 2020 12:22:24 -0700 Subject: [PATCH] Add failure logs in __ashmem_open_locked() Bug: 160984921 Test: build, boot Change-Id: I754c961289828463af6de905d8b057b4350f5f07 --- libcutils/ashmem-dev.cpp | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/libcutils/ashmem-dev.cpp b/libcutils/ashmem-dev.cpp index 20cd6592d..233d400e0 100644 --- a/libcutils/ashmem-dev.cpp +++ b/libcutils/ashmem-dev.cpp @@ -212,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) {