[fat driver] Make sure the device exists
authorcoderain <coderain@sdf.org>
Sun, 1 Oct 2017 16:37:21 +0000 (18:37 +0200)
committercoderain <coderain@sdf.org>
Sun, 1 Oct 2017 16:37:21 +0000 (18:37 +0200)
kernel/src/drivers/fs/fat.c

index f766fc052712b92cbf2a1ec4a66f0547629e09c3..ebb45d6cc7e96ecbc73034e810cb7748abe1e763 100644 (file)
@@ -608,6 +608,7 @@ static dword_t fatfs_mount(const char *device, const char *mountpoint, dword_t f
     fatfs_bpb_t bpb;
     fat_version_t type;
     device_t *block_device = get_block_device(device);
+    if (block_device == NULL) return ERR_NOTFOUND;
 
     dword_t ret = device_read(block_device, (byte_t*)&bpb, 0ULL, sizeof(fatfs_bpb_t), NULL);
     if (ret != ERR_SUCCESS) return ret;