From 7485b51d1bd37137cb12c2e4c798848ff0f2be32 Mon Sep 17 00:00:00 2001 From: lixinsheng2 Date: Thu, 22 Feb 2024 19:25:56 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8F=98=E9=87=8F=E5=9C=B0=E5=9D=80=E9=9D=9E?= =?UTF-8?q?=E6=B3=95=EF=BC=8C=E5=AF=BC=E8=87=B4=E5=BE=AA=E7=8E=AF=E5=A4=B1?= =?UTF-8?q?=E8=B4=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: lixinsheng2 --- usb/ddk/host/src/usb_interface_pool.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/usb/ddk/host/src/usb_interface_pool.c b/usb/ddk/host/src/usb_interface_pool.c index 13bb13f63..cc372c562 100644 --- a/usb/ddk/host/src/usb_interface_pool.c +++ b/usb/ddk/host/src/usb_interface_pool.c @@ -337,10 +337,9 @@ static struct UsbSdkInterface *IfFindInterfaceObj(const struct UsbInterfacePool return interfacePos; } -bool CheckInterfacePoolValid(struct DListHead *head) +static bool CheckInterfacePoolValid(struct UsbInterfacePool *interfacePoolPtr) { - struct UsbInterfacePool *interfacePoolPosNext = CONTAINER_OF(head->next, struct UsbInterfacePool, object.entry); - if (interfacePoolPosNext == NULL || (uintptr_t)interfacePoolPosNext == INVALID_PTR) { + if (interfacePoolPtr == NULL || (uintptr_t)interfacePoolPtr == INVALID_PTR) { HDF_LOGE("%{public}s:%{public}d interfacePoolPos object entry not initialized", __func__, __LINE__); return false; } @@ -397,21 +396,24 @@ static struct UsbInterfacePool *IfFindInterfacePool( return NULL; } - if (!CheckInterfacePoolValid(ifacePoolList)) { + interfacePoolPos = CONTAINER_OF(ifacePoolList->next, struct UsbInterfacePool, object.entry); + if (!CheckInterfacePoolValid(interfacePoolPos)) { OsalMutexUnlock((struct OsalMutex *)&session->lock); HDF_LOGE("%{public}s:%{public}d CheckInterfacePool invalid ", __func__, __LINE__); return NULL; } - DLIST_FOR_EACH_ENTRY_SAFE( - interfacePoolPos, interfacePoolTemp, ifacePoolList, struct UsbInterfacePool, object.entry) { + interfacePoolTemp = CONTAINER_OF(interfacePoolPos->object.entry.next, struct UsbInterfacePool, object.entry); + while (&(interfacePoolPos->object.entry) != (ifacePoolList)) { if (FoundInterfacePool(interfacePoolPos, queryPara, refCountFlag)) { found = true; break; } - if (!CheckInterfacePoolValid(&interfacePoolPos->object.entry)) { + if (!CheckInterfacePoolValid(interfacePoolTemp)) { HDF_LOGE("%{public}s:%{public}d CheckInterfacePool invalid ", __func__, __LINE__); break; } + interfacePoolPos = interfacePoolTemp; + interfacePoolTemp = CONTAINER_OF(interfacePoolPos->object.entry.next, struct UsbInterfacePool, object.entry); } OsalMutexUnlock((struct OsalMutex *)&session->lock); -- Gitee