Kernel: fix ext2 failed creation memory leak

This commit is contained in:
Bananymous 2023-04-01 00:22:03 +03:00
parent db65cfeb8a
commit c45ada6ccb
1 changed files with 2 additions and 0 deletions

View File

@ -438,8 +438,10 @@ namespace Kernel
Ext2FS* ext2fs = new Ext2FS(partition); Ext2FS* ext2fs = new Ext2FS(partition);
if (ext2fs == nullptr) if (ext2fs == nullptr)
return BAN::Error::from_errno(ENOMEM); return BAN::Error::from_errno(ENOMEM);
BAN::ScopeGuard guard([ext2fs] { delete ext2fs; });
TRY(ext2fs->initialize_superblock()); TRY(ext2fs->initialize_superblock());
TRY(ext2fs->initialize_root_inode()); TRY(ext2fs->initialize_root_inode());
guard.disable();
return ext2fs; return ext2fs;
} }