The spacc->config.modes[] array has CRYPTO_MODE_LAST number of elements so this > comparison should be >= to prevent an out of bounds access. Fixes: c8981d9230d8 ("crypto: spacc - Add SPAcc Skcipher support") Signed-off-by: Dan Carpenter <dan.carpenter@xxxxxxxxxx> --- The CRYPTO_MODE_LAST variable is poorly named. Based on the name you would expect it to be the last valid value but it's not. (I'm not a huge fan of code which uses the last valid value instead of the size personally, but the names should match). drivers/crypto/dwc-spacc/spacc_core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/crypto/dwc-spacc/spacc_core.c b/drivers/crypto/dwc-spacc/spacc_core.c index e3380528e82b..b7630f559973 100644 --- a/drivers/crypto/dwc-spacc/spacc_core.c +++ b/drivers/crypto/dwc-spacc/spacc_core.c @@ -1295,7 +1295,7 @@ int spacc_isenabled(struct spacc_device *spacc, int mode, int keysize) { int x; - if (mode < 0 || mode > CRYPTO_MODE_LAST) + if (mode < 0 || mode >= CRYPTO_MODE_LAST) return 0; if (mode == CRYPTO_MODE_NULL || -- 2.43.0