[automerger skipped] Merge "Merge sc-v2-dev-plus-aosp-without-vendor@8084891" into stage-aosp-master am: d2adcd79f8 -s ours

am skip reason: Merged-In I975390f8f495267ef0cd24dc8e73db859e541146 with SHA-1 16699d13ec is already in history

Original change: https://googleplex-android-review.googlesource.com/c/platform/hardware/libhardware/+/16844215

Change-Id: I34d543a1395a507b8fdf8fbcb797d0d2a124de4a
diff --git a/modules/sensors/dynamic_sensor/ConnectionDetector.cpp b/modules/sensors/dynamic_sensor/ConnectionDetector.cpp
index c009a70..85b9901 100644
--- a/modules/sensors/dynamic_sensor/ConnectionDetector.cpp
+++ b/modules/sensors/dynamic_sensor/ConnectionDetector.cpp
@@ -156,6 +156,10 @@
 
 void FileConnectionDetector::processExistingFiles() const {
     auto dirp = ::opendir(mPath.c_str());
+    if(dirp == NULL) {
+      ALOGE("Problem open dir %s, errno: %s", mPath.c_str(), ::strerror(errno));
+      return;
+    }
     struct dirent *dp;
     while ((dp = ::readdir(dirp)) != NULL) {
         const std::string name(dp->d_name);