From d24bbd7ad829f12d38a28e6df9670acd7d4b2b75 Mon Sep 17 00:00:00 2001 From: liubb_0516 Date: Thu, 6 Jan 2022 12:40:43 +0000 Subject: [PATCH 1/2] fixed a839a17 from https://gitee.com/liubb940516/communication_ipc_lite/pulls/31 Fix the ipc problem of duplicate handle Signed-off-by: liubb_0516 --- frameworks/liteipc_linux/src/liteipc_adapter.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/frameworks/liteipc_linux/src/liteipc_adapter.c b/frameworks/liteipc_linux/src/liteipc_adapter.c index d8f45ae..1853947 100644 --- a/frameworks/liteipc_linux/src/liteipc_adapter.c +++ b/frameworks/liteipc_linux/src/liteipc_adapter.c @@ -765,8 +765,8 @@ int32_t SendRequest(const IpcContext *context, SvcIdentity sid, uint32_t code, return ret; } buf.cmd = BC_TRANSACTION; + IpcIo tempIo; if (data == NULL) { - IpcIo tempIo; data = &tempIo; uint8_t tmpData[IPC_IO_DATA_TEMP]; IpcIoInit(data, tmpData, IPC_IO_DATA_TEMP, 0); @@ -851,8 +851,8 @@ int32_t SendReply(const IpcContext* context, void* ipcMsg, IpcIo* reply) struct TransactData buf = {0}; buf.cmd = BC_REPLY; SvcIdentity sid = {0}; + IpcIo tempIo; if (reply == NULL) { - IpcIo tempIo; reply = &tempIo; uint8_t tmpData[IPC_IO_DATA_TEMP]; IpcIoInit(reply, tmpData, IPC_IO_DATA_TEMP, 0); -- Gitee From 0e0531d3111b238694febc308e37bb44298ffddd Mon Sep 17 00:00:00 2001 From: liubb_0516 Date: Thu, 6 Jan 2022 11:36:26 +0000 Subject: [PATCH 2/2] fixed d3fb20a from https://gitee.com/liubb940516/communication_ipc_lite/pulls/31 Fix the ipc problem of duplicate handle Signed-off-by: liubb_0516 --- frameworks/liteipc_linux/src/liteipc_adapter.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/frameworks/liteipc_linux/src/liteipc_adapter.c b/frameworks/liteipc_linux/src/liteipc_adapter.c index 1853947..3141362 100644 --- a/frameworks/liteipc_linux/src/liteipc_adapter.c +++ b/frameworks/liteipc_linux/src/liteipc_adapter.c @@ -430,14 +430,13 @@ static void HandleTransaction(const IpcContext *context, const struct binder_tra return; } g_handle = remote->handle; - free(remote); - remote = NULL; data->data = io.bufferCur; data->offsets = io.offsetsCur; data->dataSz = io.bufferLeft; data->spObjNum = io.offsetsLeft; if (IsValidCB(data)) { TryCallBack(context, data, &io, NULL); + free(remote); return; } data->target.token = token; @@ -445,10 +444,12 @@ static void HandleTransaction(const IpcContext *context, const struct binder_tra if (GetFuncPair(&pair, txn->cookie)) { pair.func(context, data, &io, pair.argv); } else if (GetFuncPair(&pair, g_samgrId)) { + data->target.handle = remote->handle; pair.func(context, data, &io, pair.argv); } else { LOG(ERROR, "BR_TRANSACTION should not happen!"); } + free(remote); } static void HandleReply(IpcIo* bio, const struct binder_transaction_data *txn, uintptr_t* buffer) -- Gitee