1
0
Fork 0
mirror of https://github.com/iNavFlight/inav.git synced 2025-07-26 09:45:33 +03:00

Fix array out of bounds issue in I2C driver

This commit is contained in:
Konstantin Sharlaimov (DigitalEntity) 2017-01-02 23:19:00 +10:00
parent 37afad6e07
commit 1e5ed2774b
3 changed files with 4 additions and 2 deletions

View file

@ -39,6 +39,8 @@ typedef enum I2CDevice {
I2CDEV_MAX = I2CDEV_3,
} I2CDevice;
#define I2CDEV_COUNT (I2CDEV_MAX + 1)
typedef struct i2cDevice_s {
I2C_TypeDef *dev;
ioTag_t scl;

View file

@ -140,7 +140,7 @@ static i2cDevice_t i2cHardwareMap[] = {
#endif
};
static i2cBusState_t busState[I2CDEV_MAX] = { { 0 } };
static i2cBusState_t busState[I2CDEV_COUNT] = { { 0 } };
static void i2cResetInterface(i2cBusState_t * i2cBusState)
{

View file

@ -106,7 +106,7 @@ static i2cDevice_t i2cHardwareMap[] = {
{ .dev = I2C2, .scl = IO_TAG(I2C2_SCL), .sda = IO_TAG(I2C2_SDA), .rcc = RCC_APB1(I2C2), .overClock = I2C2_OVERCLOCK }
};
static i2cBusState_t busState[I2CDEV_MAX] = { { 0 } };
static i2cBusState_t busState[I2CDEV_COUNT] = { { 0 } };
static void i2cResetInterface(i2cBusState_t * i2cBusState)
{