drivers/mtd/smart.c: Fix a Smart wear-leveling bug. From Ken Petit
This commit is contained in:
parent
7e58e4c4cf
commit
f0f7dd9956
|
@ -11107,3 +11107,5 @@
|
|||
CRC calculation. From Karim Keddam (2015-11-17).
|
||||
* drivers/mtd/w25.c: Fix W25 FLASH driver page read/write logic. From
|
||||
Ken Petit (2015-11-18).
|
||||
* drivers/mtd/smart.c: Fix a Smart wear-leveling bug. From Ken Petit
|
||||
(2015-11-18).
|
||||
|
|
|
@ -3895,9 +3895,9 @@ static inline int smart_read_wearstatus(FAR struct smart_struct_s *dev)
|
|||
/* Calculate number of bytes to read from this sector */
|
||||
|
||||
toread = remaining;
|
||||
if (toread > dev->sectorsize - SMARTFS_FMT_WEAR_POS)
|
||||
if (toread > dev->sectorsize - (SMARTFS_FMT_WEAR_POS + sizeof(struct smart_sect_header_s)))
|
||||
{
|
||||
toread = dev->sectorsize - SMARTFS_FMT_WEAR_POS;
|
||||
toread = dev->sectorsize - (SMARTFS_FMT_WEAR_POS + sizeof(struct smart_sect_header_s));
|
||||
}
|
||||
|
||||
/* Setup the sector read request (we are our own client) */
|
||||
|
@ -4509,7 +4509,8 @@ static int smart_readsector(FAR struct smart_struct_s *dev,
|
|||
fvdbg("Entry\n");
|
||||
req = (FAR struct smart_read_write_s *) arg;
|
||||
DEBUGASSERT(req->offset < dev->sectorsize);
|
||||
DEBUGASSERT(req->offset+req->count < dev->sectorsize);
|
||||
DEBUGASSERT(req->offset+req->count+ sizeof(struct smart_sect_header_s) <=
|
||||
dev->sectorsize);
|
||||
|
||||
/* Ensure the logical sector has been allocated */
|
||||
|
||||
|
|
Loading…
Reference in New Issue