diff options
author | Zhaoming Yin <zhaomingyin@google.com> | 2022-01-16 08:12:51 -0800 |
---|---|---|
committer | Zhaoming Yin <zhaomingyin@google.com> | 2022-01-20 01:32:19 +0000 |
commit | 78e7f9c0f161e0bfbeabd51dca0ac0d2796fb665 (patch) | |
tree | e6abc08851c027058b0050f65741a12c16e83ad4 | |
parent | 0b5ab223e110f3a34b30e7b61e4ea68c03dba98b (diff) | |
download | libhardware-78e7f9c0f161e0bfbeabd51dca0ac0d2796fb665.tar.gz |
Fix opendir NULL dirp return issue
Bug: 206035991
Test: use forrest to run boottest
Change-Id: I9e77b7d6184a0ee132b8f058f7f83302c54bcb4a
(cherry picked from commit c76c1d579965d967ff99264a16342ee33ae870c6)
-rw-r--r-- | modules/sensors/dynamic_sensor/ConnectionDetector.cpp | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/modules/sensors/dynamic_sensor/ConnectionDetector.cpp b/modules/sensors/dynamic_sensor/ConnectionDetector.cpp index c009a707..85b99017 100644 --- a/modules/sensors/dynamic_sensor/ConnectionDetector.cpp +++ b/modules/sensors/dynamic_sensor/ConnectionDetector.cpp @@ -156,6 +156,10 @@ std::string FileConnectionDetector::getFullName(const std::string name) const { 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); |