commit | c76c1d579965d967ff99264a16342ee33ae870c6 | [log] [tgz] |
---|---|---|
author | Zhaoming Yin <zhaomingyin@google.com> | Sun Jan 16 08:12:51 2022 -0800 |
committer | Zhaoming Yin <zhaomingyin@google.com> | Sun Jan 16 08:13:00 2022 -0800 |
tree | c92271415a9d75cbdf64e286c06793009fc0d28d | |
parent | d3e67d55acd051c3fe1877bc0ce3081e39a15c8d [diff] |
Fix opendir NULL dirp return issue Bug: 206035991 Test: use forrest to run boottest Change-Id: I9e77b7d6184a0ee132b8f058f7f83302c54bcb4a
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);