drivers: stm32_fmc2_nand: fix boundary check for chip select

Chip select is retrieved from device tree and check
must be done regarding the MAX_CS defined.

Signed-off-by: Lionel Debieve <lionel.debieve@st.com>
Reviewed-by: Christophe KERELLO <christophe.kerello@st.com>
Change-Id: I03144b133bd51a845a4794f0f6bbd9402fc04936
This commit is contained in:
Lionel Debieve 2020-07-21 15:22:55 +02:00
parent 0c3e8acbd6
commit 495885bce6
1 changed files with 5 additions and 0 deletions

View File

@ -908,7 +908,12 @@ int stm32_fmc2_init(void)
WARN("Chip select not well defined\n");
return -FDT_ERR_BADVALUE;
}
stm32_fmc2.cs_sel = fdt32_to_cpu(*cuint);
if (stm32_fmc2.cs_sel >= MAX_CS) {
return -FDT_ERR_BADVALUE;
}
VERBOSE("NAND CS %i\n", stm32_fmc2.cs_sel);
}