diff --git a/OvmfPkg/VirtioFsDxe/SimpleFsClose.c b/OvmfPkg/VirtioFsDxe/SimpleFsClose.c index bc91ad726b..04b4f2c382 100644 --- a/OvmfPkg/VirtioFsDxe/SimpleFsClose.c +++ b/OvmfPkg/VirtioFsDxe/SimpleFsClose.c @@ -59,6 +59,7 @@ VirtioFsSimpleFileClose ( // RemoveEntryList (&VirtioFsFile->OpenFilesEntry); + FreePool (VirtioFsFile->CanonicalPathname); FreePool (VirtioFsFile); return EFI_SUCCESS; } diff --git a/OvmfPkg/VirtioFsDxe/SimpleFsDelete.c b/OvmfPkg/VirtioFsDxe/SimpleFsDelete.c index bbad64bf78..e2fc2d72df 100644 --- a/OvmfPkg/VirtioFsDxe/SimpleFsDelete.c +++ b/OvmfPkg/VirtioFsDxe/SimpleFsDelete.c @@ -63,6 +63,7 @@ VirtioFsSimpleFileDelete ( // RemoveEntryList (&VirtioFsFile->OpenFilesEntry); + FreePool (VirtioFsFile->CanonicalPathname); FreePool (VirtioFsFile); return Status; } diff --git a/OvmfPkg/VirtioFsDxe/SimpleFsOpenVolume.c b/OvmfPkg/VirtioFsDxe/SimpleFsOpenVolume.c index 67d2deb6bd..9c0ab434c1 100644 --- a/OvmfPkg/VirtioFsDxe/SimpleFsOpenVolume.c +++ b/OvmfPkg/VirtioFsDxe/SimpleFsOpenVolume.c @@ -28,6 +28,7 @@ VirtioFsOpenVolume ( VIRTIO_FS *VirtioFs; VIRTIO_FS_FILE *VirtioFsFile; EFI_STATUS Status; + CHAR8 *CanonicalPathname; UINT64 RootDirHandle; VirtioFs = VIRTIO_FS_FROM_SIMPLE_FS (This); @@ -37,13 +38,19 @@ VirtioFsOpenVolume ( return EFI_OUT_OF_RESOURCES; } + CanonicalPathname = AllocateCopyPool (sizeof "/", "/"); + if (CanonicalPathname == NULL) { + Status = EFI_OUT_OF_RESOURCES; + goto FreeVirtioFsFile; + } + // // Open the root directory. // Status = VirtioFsFuseOpenDir (VirtioFs, VIRTIO_FS_FUSE_ROOT_DIR_NODE_ID, &RootDirHandle); if (EFI_ERROR (Status)) { - goto FreeVirtioFsFile; + goto FreeCanonicalPathname; } // @@ -64,6 +71,7 @@ VirtioFsOpenVolume ( VirtioFsFile->IsDirectory = TRUE; VirtioFsFile->IsOpenForWriting = FALSE; VirtioFsFile->OwnerFs = VirtioFs; + VirtioFsFile->CanonicalPathname = CanonicalPathname; VirtioFsFile->NodeId = VIRTIO_FS_FUSE_ROOT_DIR_NODE_ID; VirtioFsFile->FuseHandle = RootDirHandle; @@ -75,6 +83,9 @@ VirtioFsOpenVolume ( *Root = &VirtioFsFile->SimpleFile; return EFI_SUCCESS; +FreeCanonicalPathname: + FreePool (CanonicalPathname); + FreeVirtioFsFile: FreePool (VirtioFsFile); diff --git a/OvmfPkg/VirtioFsDxe/VirtioFsDxe.h b/OvmfPkg/VirtioFsDxe/VirtioFsDxe.h index f4fed64c72..487d215c7f 100644 --- a/OvmfPkg/VirtioFsDxe/VirtioFsDxe.h +++ b/OvmfPkg/VirtioFsDxe/VirtioFsDxe.h @@ -137,6 +137,7 @@ typedef struct { BOOLEAN IsOpenForWriting; VIRTIO_FS *OwnerFs; LIST_ENTRY OpenFilesEntry; + CHAR8 *CanonicalPathname; // // In the FUSE wire protocol, every request except FUSE_INIT refers to a // file, namely by the "VIRTIO_FS_FUSE_REQUEST.NodeId" field; that is, by the