diff options
author | Nick Withers <nick.withers@anu.edu.au> | 2014-01-30 12:58:41 +1100 |
---|---|---|
committer | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2014-12-03 07:51:02 +0100 |
commit | fa4fe456b7f0c561e73477df59b2f9376f23b080 (patch) | |
tree | 4c54fa3fad4c0844b712e2cf5fe861eea958a372 | |
parent | sparc/leon2: LEON_Is_interrupt_masked for Leon2 in leon.h wrongly defined (diff) | |
download | rtems-fa4fe456b7f0c561e73477df59b2f9376f23b080.tar.bz2 |
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.
-rw-r--r-- | c/src/lib/libbsp/powerpc/shared/flash/flash.c | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/c/src/lib/libbsp/powerpc/shared/flash/flash.c b/c/src/lib/libbsp/powerpc/shared/flash/flash.c index 0037fe73e2..b7f167875a 100644 --- a/c/src/lib/libbsp/powerpc/shared/flash/flash.c +++ b/c/src/lib/libbsp/powerpc/shared/flash/flash.c @@ -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; |