diff options
author | Qing Huang <qing.huang@intel.com> | 2010-05-07 03:31:16 +0000 |
---|---|---|
committer | Jordan Justen <jordan.l.justen@intel.com> | 2016-04-06 23:22:43 -0700 |
commit | 5251cb9d68ab96da99e284a3b01aa645c3dc7ddb (patch) | |
tree | bf2701e067507cf276398a11b1e13a6e5b2b7bcb /FatPkg/EnhancedFatDxe/Fat.c | |
parent | 6163cc98b61a914a2775aed34d90c4d25cc56777 (diff) | |
download | edk2-5251cb9d68ab96da99e284a3b01aa645c3dc7ddb.tar.gz edk2-5251cb9d68ab96da99e284a3b01aa645c3dc7ddb.tar.bz2 edk2-5251cb9d68ab96da99e284a3b01aa645c3dc7ddb.zip |
Move lock to FAT driver binding start to prevent interrupt during hot plug event.
(based on FatPkg commit b449ca31443f754ed2e6998ca32f49547dabd615)
[jordan.l.justen@intel.com: Use script to relicense to 2-clause BSD]
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Jordan Justen <jordan.l.justen@intel.com>
Acked-by: Mark Doran <mark.doran@intel.com>
Acked-by: Laszlo Ersek <lersek@redhat.com>
Diffstat (limited to 'FatPkg/EnhancedFatDxe/Fat.c')
-rw-r--r-- | FatPkg/EnhancedFatDxe/Fat.c | 26 |
1 files changed, 22 insertions, 4 deletions
diff --git a/FatPkg/EnhancedFatDxe/Fat.c b/FatPkg/EnhancedFatDxe/Fat.c index 67ee66c026..38b70882c5 100644 --- a/FatPkg/EnhancedFatDxe/Fat.c +++ b/FatPkg/EnhancedFatDxe/Fat.c @@ -1,6 +1,6 @@ /*++
-Copyright (c) 2005 - 2007, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2005 - 2010, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials are licensed and made available
under the terms and conditions of the BSD License which accompanies this
distribution. The full text of the license may be found at
@@ -269,10 +269,21 @@ Returns: EFI_STATUS Status;
EFI_BLOCK_IO_PROTOCOL *BlockIo;
EFI_DISK_IO_PROTOCOL *DiskIo;
+ BOOLEAN LockedByMe;
+
+ LockedByMe = FALSE;
+ //
+ // Acquire the lock.
+ // If caller has already acquired the lock, cannot lock it again.
+ //
+ Status = FatAcquireLockOrFail ();
+ if (!EFI_ERROR (Status)) {
+ LockedByMe = TRUE;
+ }
Status = InitializeUnicodeCollationSupport (This->DriverBindingHandle);
if (EFI_ERROR (Status)) {
- return Status;
+ goto Exit;
}
//
// Open our required BlockIo and DiskIo
@@ -286,7 +297,7 @@ Returns: EFI_OPEN_PROTOCOL_GET_PROTOCOL
);
if (EFI_ERROR (Status)) {
- return Status;
+ goto Exit;
}
Status = gBS->OpenProtocol (
@@ -298,7 +309,7 @@ Returns: EFI_OPEN_PROTOCOL_BY_DRIVER
);
if (EFI_ERROR (Status)) {
- return Status;
+ goto Exit;
}
//
// Allocate Volume structure. In FatAllocateVolume(), Resources
@@ -330,6 +341,13 @@ Returns: }
}
+Exit:
+ //
+ // Unlock if locked by myself.
+ //
+ if (LockedByMe) {
+ FatReleaseLock ();
+ }
return Status;
}
|