forked from Bananymous/banan-os
Kernel: fix ext2 failed creation memory leak
This commit is contained in:
parent
3a4557d417
commit
5da801d12b
|
@ -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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue