diff --git a/adapter/uhdf2/hdi/src/idevmgr_client.cpp b/adapter/uhdf2/hdi/src/idevmgr_client.cpp index 57a07348ebb9d3299c495836f923484d24fe0f8b..a339d72439da5f8fb1797a5612f305d0b1564679 100644 --- a/adapter/uhdf2/hdi/src/idevmgr_client.cpp +++ b/adapter/uhdf2/hdi/src/idevmgr_client.cpp @@ -68,6 +68,10 @@ int32_t DeviceManagerProxy::LoadDevice(const std::string &serviceName) } std::unique_lock lock(g_remoteMutex); + if (Remote() == nullptr) { + HDF_LOGE("invalid param Remote()"); + return HDF_ERR_INVALID_PARAM; + } int status = Remote()->SendRequest(DEVMGR_SERVICE_LOAD_DEVICE, data, reply, option); lock.unlock(); if (status != HDF_SUCCESS) { @@ -90,6 +94,10 @@ int32_t DeviceManagerProxy::UnloadDevice(const std::string &serviceName) } std::unique_lock lock(g_remoteMutex); + if (Remote() == nullptr) { + HDF_LOGE("invalid param Remote()"); + return HDF_ERR_INVALID_PARAM; + } int status = Remote()->SendRequest(DEVMGR_SERVICE_UNLOAD_DEVICE, data, reply, option); lock.unlock(); if (status != HDF_SUCCESS) { @@ -157,6 +165,10 @@ int32_t DeviceManagerProxy::ListAllDevice(std::vector &deviceInf MessageOption option; std::unique_lock lock(g_remoteMutex); + if (Remote() == nullptr) { + HDF_LOGE("invalid param Remote()"); + return HDF_ERR_INVALID_PARAM; + } int status = Remote()->SendRequest(DEVMGR_SERVICE_LIST_ALL_DEVICE, data, reply, option); lock.unlock(); if (status != HDF_SUCCESS) { diff --git a/adapter/uhdf2/hdi/src/iservmgr_client.cpp b/adapter/uhdf2/hdi/src/iservmgr_client.cpp index 66e7d3e278f40d2d34393c77af41d607cba2dfd1..d058a5793e10257b9c1b52faec17127d776c5e60 100644 --- a/adapter/uhdf2/hdi/src/iservmgr_client.cpp +++ b/adapter/uhdf2/hdi/src/iservmgr_client.cpp @@ -83,6 +83,10 @@ int32_t ServiceManagerProxy::RegisterServiceStatusListener( } std::unique_lock lock(g_remoteMutex); + if (Remote() == nullptr) { + HDF_LOGE("invalid param Remote()"); + return HDF_ERR_INVALID_PARAM; + } int status = Remote()->SendRequest( static_cast(HdfDeviceManagerInterfaceCode::DEVSVC_MANAGER_REGISTER_SVCLISTENER), data, reply, option); lock.unlock(); @@ -103,6 +107,10 @@ int32_t ServiceManagerProxy::UnregisterServiceStatusListener(::OHOS::sptr lock(g_remoteMutex); + if (Remote() == nullptr) { + HDF_LOGE("invalid param Remote()"); + return HDF_ERR_INVALID_PARAM; + } int status = Remote()->SendRequest( static_cast(HdfDeviceManagerInterfaceCode::DEVSVC_MANAGER_UNREGISTER_SVCLISTENER), data, reply, option); @@ -123,6 +131,10 @@ sptr ServiceManagerProxy::GetService(const char *serviceName) MessageOption option; std::unique_lock lock(g_remoteMutex); + if (Remote() == nullptr) { + HDF_LOGE("invalid param Remote()"); + return nullptr; + } int status = Remote()->SendRequest( static_cast(HdfDeviceManagerInterfaceCode::DEVSVC_MANAGER_GET_SERVICE), data, reply, option); lock.unlock(); @@ -160,6 +172,10 @@ int32_t ServiceManagerProxy::ListAllService(std::vector &service MessageOption option; std::unique_lock lock(g_remoteMutex); + if (Remote() == nullptr) { + HDF_LOGE("invalid param Remote()"); + return HDF_ERR_INVALID_PARAM; + } int status = Remote()->SendRequest( static_cast(HdfDeviceManagerInterfaceCode::DEVSVC_MANAGER_LIST_ALL_SERVICE), data, reply, option); lock.unlock(); @@ -188,6 +204,10 @@ int32_t ServiceManagerProxy::ListServiceByInterfaceDesc( MessageOption option; std::unique_lock lock(g_remoteMutex); + if (Remote() == nullptr) { + HDF_LOGE("invalid param Remote()"); + return HDF_ERR_INVALID_PARAM; + } int status = Remote()->SendRequest( static_cast(HdfDeviceManagerInterfaceCode::DEVSVC_MANAGER_LIST_SERVICE_BY_INTERFACEDESC), data, reply, option);