diff --git a/services/sensor/hdi_connection/interface/src/sensor_hdi_connection.cpp b/services/sensor/hdi_connection/interface/src/sensor_hdi_connection.cpp index 78e631623b4efe91ce2f5addaeaa063ad11117f3..0d5c04fd5e76c38d78ef2304549bc928066ae11a 100644 --- a/services/sensor/hdi_connection/interface/src/sensor_hdi_connection.cpp +++ b/services/sensor/hdi_connection/interface/src/sensor_hdi_connection.cpp @@ -22,7 +22,6 @@ namespace OHOS { namespace Sensors { using namespace OHOS::HiviewDFX; - namespace { constexpr HiLogLabel LABEL = { LOG_CORE, SensorsLogDomain::SENSOR_SERVICE, "SensorHdiConnection" }; } @@ -30,6 +29,10 @@ constexpr HiLogLabel LABEL = { LOG_CORE, SensorsLogDomain::SENSOR_SERVICE, "Sens int32_t SensorHdiConnection::ConnectHdi() { iSensorHdiConnection_ = std::make_unique(); + if (iSensorHdiConnection_ == nullptr) { + HiLog::Error(LABEL, "%{public}s failed, iSensorHdiConnection_ cannot be null", __func__); + return ERROR; + } int32_t ret = connectHdiService(); if (ret != ERR_OK) { HiLog::Error(LABEL, "%{public}s connect hdi service failed, try to connect compatible connection",