SecurityPkg/Tcg/OpalPasswordDxe: Fix logic for RemoveDevice()

First, If there are multiple devices in DeviceList and are going to
remove the first device in the DeviceList, the DeviceList will be
cleared up with setting to NULL.
This is not the expected behavior, as it should keep the rest of the
devices in the DeviceList. DeviceList should point to the next device,
Dev->Next.

Second, there is a potential infinite while loop if TmpDev->Next not
equal to Dev. TmpDev should point to next device.

Signed-off-by: Hunter Chang <hunter.chang@intel.com>
This commit is contained in:
Hunter Chang
2025-07-25 13:31:35 +08:00
committed by mergify[bot]
parent bd785cedc3
commit 504a80c151

View File

@@ -2329,7 +2329,7 @@ RemoveDevice (
}
if (mOpalDriver.DeviceList == Dev) {
mOpalDriver.DeviceList = NULL;
mOpalDriver.DeviceList = Dev->Next;
return;
}
@@ -2339,6 +2339,8 @@ RemoveDevice (
TmpDev->Next = Dev->Next;
break;
}
TmpDev = TmpDev->Next;
}
}