Merge pull request #7470 from jflyper/bfdev-protect-flashInit-from-NULL-SPI-instance

[FLASH] Protect flashInit from NULL SPI instance
This commit is contained in:
Michael Keller 2019-01-28 20:14:40 +13:00 committed by GitHub
commit 28de73ab13
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 7 additions and 1 deletions

View File

@ -62,7 +62,13 @@ bool flashInit(const flashConfig_t *flashConfig)
}
busdev->bustype = BUSTYPE_SPI;
spiBusSetInstance(busdev, spiInstanceByDevice(SPI_CFG_TO_DEV(flashConfig->spiDevice)));
SPI_TypeDef *instance = spiInstanceByDevice(SPI_CFG_TO_DEV(flashConfig->spiDevice));
if (!instance) {
return false;
}
spiBusSetInstance(busdev, instance);
IOInit(busdev->busdev_u.spi.csnPin, OWNER_FLASH_CS, 0);
IOConfigGPIO(busdev->busdev_u.spi.csnPin, SPI_IO_CS_CFG);