forked from Imagelibrary/rtems
Move the flash size probe into bankValidate()
Previously, bankValidate() could be called (e.g., BSP_flashWrite() -> regionCheckAndErase() -> argcheck() -> bankValidate()) without the probe having happened. When it then invoked BSP_flashCheckId(), unmapped memory could be read, possibly causing a fatal exception.
This commit is contained in:
committed by
Sebastian Huber
parent
2501814ee9
commit
fa4fe456b7
@@ -456,6 +456,11 @@ struct bankdesc *b = BSP_flashBspOps.bankcheck(bank, quiet);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if ( !b->size && !(b->size = BSP_flashProbeSize(b)) ) {
|
||||
fprintf(stderr,"Configuration Error - unable to determine flash size\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
if ( !b->dd && !(b->dd = BSP_flashCheckId(b, b->start,1)) ) {
|
||||
fprintf(stderr,"Error: unable to detect flash device in bank #%i\n", bank);
|
||||
return 0;
|
||||
@@ -485,10 +490,6 @@ struct bankdesc *b;
|
||||
return 0;
|
||||
}
|
||||
|
||||
if ( !b->size && !(b->size = BSP_flashProbeSize(b)) ) {
|
||||
fprintf(stderr,"Configuration Error - unable to determine flash size\n");
|
||||
return 0;
|
||||
}
|
||||
if ( offset + size > b->size ) {
|
||||
fprintf(stderr,"Error: requested size exceeds available flash (0x%08"PRIx32" bytes)\n", b->size);
|
||||
return 0;
|
||||
|
||||
Reference in New Issue
Block a user