!11 fix: resolve the memory free problem of the service status notification module

Merge pull request !11 from Zhang/OpenHarmony-3.2-Beta1
This commit is contained in:
openharmony_ci 2022-07-05 07:51:59 +00:00 committed by Gitee
commit db20ee2467
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
2 changed files with 11 additions and 4 deletions

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
* Copyright (c) 2021-2022 Huawei Device Co., Ltd.
*
* HDF is dual licensed: you can use it either under the terms of
* the GPL, or the BSD license, at your option.
@ -62,6 +62,7 @@ int32_t KServStatListenerHolderNotifyStatus(struct ServStatListenerHolder *holde
if (HdfDeviceSendEventToClient(holderInst->listenerClient, 0, data) != HDF_SUCCESS) {
HDF_LOGE("failed to notify service status, send error");
HdfSbufRecycle(data);
return HDF_FAILURE;
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
* Copyright (c) 2021-2022 Huawei Device Co., Ltd.
*
* HDF is dual licensed: you can use it either under the terms of
* the GPL, or the BSD license, at your option.
@ -31,10 +31,13 @@ static int32_t SetListenClass(struct SvcMgrIoservice *svcmgrInst, uint16_t devCl
(void)HdfSbufWriteUint16(data, devClass);
if (svcmgrInst->iosvc == NULL || svcmgrInst->iosvc->dispatcher == NULL
|| svcmgrInst->iosvc->dispatcher->Dispatch == NULL) {
HdfSbufRecycle(data);
return HDF_ERR_INVALID_OBJECT;
}
return svcmgrInst->iosvc->dispatcher->Dispatch(
int32_t ret = svcmgrInst->iosvc->dispatcher->Dispatch(
(struct HdfObject *)svcmgrInst->iosvc, SVCMGR_REGISTER_LISTENER, data, NULL);
HdfSbufRecycle(data);
return ret;
}
static int32_t UnSetListenClass(struct SvcMgrIoservice *svcmgrInst, uint16_t devClass)
@ -47,10 +50,13 @@ static int32_t UnSetListenClass(struct SvcMgrIoservice *svcmgrInst, uint16_t dev
(void)HdfSbufWriteUint16(data, devClass);
if (svcmgrInst->iosvc == NULL || svcmgrInst->iosvc->dispatcher == NULL
|| svcmgrInst->iosvc->dispatcher->Dispatch == NULL) {
HdfSbufRecycle(data);
return HDF_ERR_INVALID_OBJECT;
}
return svcmgrInst->iosvc->dispatcher->Dispatch(
int32_t ret = svcmgrInst->iosvc->dispatcher->Dispatch(
(struct HdfObject *)svcmgrInst->iosvc, SVCMGR_UNREGISTER_LISTENER, data, NULL);
HdfSbufRecycle(data);
return ret;
}
int32_t SvcMgrIoserviceRegSvcStatListener(