summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHunter Chang <hunter.chang@intel.com>2025-07-25 13:31:35 +0800
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>2025-08-07 06:40:28 +0000
commit504a80c1514d824dba8a883373912b0f78e0f0ee (patch)
tree290cd30224fb05be8b783699dd9ad0a1d3ea72b4
parentbd785cedc370c96b736e8a3db9526aca436cb7de (diff)
downloadedk2-504a80c1514d824dba8a883373912b0f78e0f0ee.zip
edk2-504a80c1514d824dba8a883373912b0f78e0f0ee.tar.gz
edk2-504a80c1514d824dba8a883373912b0f78e0f0ee.tar.bz2
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>
-rw-r--r--SecurityPkg/Tcg/Opal/OpalPassword/OpalDriver.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/SecurityPkg/Tcg/Opal/OpalPassword/OpalDriver.c b/SecurityPkg/Tcg/Opal/OpalPassword/OpalDriver.c
index 068c3c7..c41fe6f 100644
--- a/SecurityPkg/Tcg/Opal/OpalPassword/OpalDriver.c
+++ b/SecurityPkg/Tcg/Opal/OpalPassword/OpalDriver.c
@@ -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;
}
}