summaryrefslogtreecommitdiff
path: root/kernel/fs/ext2.c
diff options
context:
space:
mode:
authorAnton Kling <anton@kling.gg>2024-04-26 16:06:35 +0200
committerAnton Kling <anton@kling.gg>2024-04-26 16:20:59 +0200
commit59e3f74a2e1a0806350e1ffd77a528821d1f2be3 (patch)
treea514572b0b9468f6ae3ba7cd075181c58c2371e7 /kernel/fs/ext2.c
parent15bc439577c49e97c24a074fe6d9e9464f917054 (diff)
Kernel: More out of memory condition checks
Diffstat (limited to 'kernel/fs/ext2.c')
-rw-r--r--kernel/fs/ext2.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/kernel/fs/ext2.c b/kernel/fs/ext2.c
index b11bc9c..046408c 100644
--- a/kernel/fs/ext2.c
+++ b/kernel/fs/ext2.c
@@ -800,8 +800,15 @@ int ext2_create_file(const char *path, int mode) {
}
vfs_inode_t *ext2_mount(void) {
- int fd = vfs_open("/dev/sda", O_RDWR, 0);
cache = kcalloc(3000, sizeof(struct BLOCK_CACHE));
+ if (!cache) {
+ return NULL;
+ }
+ int fd = vfs_open("/dev/sda", O_RDWR, 0);
+ if(0 > fd) {
+ kfree(cache);
+ return NULL;
+ }
// TODO: Can this be done better? Maybe create a seperate function in
// the VFS?
mount_fd = get_vfs_fd(fd, NULL);