From c06fa6d9443d7107fd526afe929b2da020a04cee Mon Sep 17 00:00:00 2001 From: huyx Date: Mon, 5 Aug 2024 22:18:27 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E4=BB=A3=E7=A0=81=E6=8E=92=E9=9B=B7?= =?UTF-8?q?=E6=95=B4=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: huyx --- adapter/uhdf2/hdi/src/idevmgr_client.cpp | 12 ++++++++++++ adapter/uhdf2/hdi/src/iservmgr_client.cpp | 20 ++++++++++++++++++++ 2 files changed, 32 insertions(+) diff --git a/adapter/uhdf2/hdi/src/idevmgr_client.cpp b/adapter/uhdf2/hdi/src/idevmgr_client.cpp index 57a07348e..a339d7243 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 66e7d3e27..ec4e5538e 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 HDF_ERR_INVALID_PARAM; + } 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); -- Gitee From 41e095aa3c93b5992a0007faa964dc2d2eef924a Mon Sep 17 00:00:00 2001 From: huyx Date: Tue, 6 Aug 2024 10:31:01 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E6=8E=92=E9=9B=B7=E6=95=B4=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: huyx --- adapter/uhdf2/hdi/src/iservmgr_client.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/adapter/uhdf2/hdi/src/iservmgr_client.cpp b/adapter/uhdf2/hdi/src/iservmgr_client.cpp index ec4e5538e..d058a5793 100644 --- a/adapter/uhdf2/hdi/src/iservmgr_client.cpp +++ b/adapter/uhdf2/hdi/src/iservmgr_client.cpp @@ -133,7 +133,7 @@ sptr ServiceManagerProxy::GetService(const char *serviceName) std::unique_lock lock(g_remoteMutex); if (Remote() == nullptr) { HDF_LOGE("invalid param Remote()"); - return HDF_ERR_INVALID_PARAM; + return nullptr; } int status = Remote()->SendRequest( static_cast(HdfDeviceManagerInterfaceCode::DEVSVC_MANAGER_GET_SERVICE), data, reply, option); -- Gitee