Skip to content

Commit 997de94

Browse files
Unbear-HzRbb666
authored andcommitted
[fix][dfs] elmfat磁盘操作设备指针判空
1 parent aff4723 commit 997de94

2 files changed

Lines changed: 12 additions & 0 deletions

File tree

components/dfs/dfs_v1/filesystems/elmfat/dfs_elm.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -908,6 +908,9 @@ DRESULT disk_read(BYTE drv, BYTE *buff, DWORD sector, UINT count)
908908
rt_size_t result;
909909
rt_device_t device = disk[drv];
910910

911+
if (device == RT_NULL)
912+
return RES_ERROR;
913+
911914
result = rt_device_read(device, sector, buff, count);
912915
if (result == count)
913916
{
@@ -923,6 +926,9 @@ DRESULT disk_write(BYTE drv, const BYTE *buff, DWORD sector, UINT count)
923926
rt_size_t result;
924927
rt_device_t device = disk[drv];
925928

929+
if (device == RT_NULL)
930+
return RES_ERROR;
931+
926932
result = rt_device_write(device, sector, buff, count);
927933
if (result == count)
928934
{

components/dfs/dfs_v2/filesystems/elmfat/dfs_elm.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1146,6 +1146,9 @@ DRESULT disk_read(BYTE drv, BYTE *buff, DWORD sector, UINT count)
11461146
rt_size_t result;
11471147
rt_device_t device = disk[drv];
11481148

1149+
if (device == RT_NULL)
1150+
return RES_ERROR;
1151+
11491152
result = rt_device_read(device, sector, buff, count);
11501153
if (result == count)
11511154
{
@@ -1161,6 +1164,9 @@ DRESULT disk_write(BYTE drv, const BYTE *buff, DWORD sector, UINT count)
11611164
rt_size_t result;
11621165
rt_device_t device = disk[drv];
11631166

1167+
if (device == RT_NULL)
1168+
return RES_ERROR;
1169+
11641170
result = rt_device_write(device, sector, buff, count);
11651171
if (result == count)
11661172
{

0 commit comments

Comments
 (0)