From aa9b762d127185d241d69d045650ae1d11e16d01 Mon Sep 17 00:00:00 2001 From: Maureen Helm Date: Thu, 29 Aug 2019 16:29:39 -0500 Subject: [PATCH] disk: Fix usdhc driver out-of-bounds array access The usdhc driver was incorrectly post-decrementing a do/while loop iterator, causing an extra iteration of the loop and an out-of-bounds array access. Change the iterator to decrement within the loop instead. Tested samples/subsys/fs/fat_fs on the mimxrt1050_evk board. Coverity-CID: 203403 Signed-off-by: Maureen Helm --- subsys/disk/disk_access_usdhc.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/subsys/disk/disk_access_usdhc.c b/subsys/disk/disk_access_usdhc.c index ca93a95933..53a22abdc9 100644 --- a/subsys/disk/disk_access_usdhc.c +++ b/subsys/disk/disk_access_usdhc.c @@ -1101,7 +1101,8 @@ static int usdhc_cmd_rsp(struct usdhc_priv *priv) ((cmd->response[i - 2U] & 0xFF000000U) >> 24U); } - } while (i--); + i--; + } while (i); } } /* check response error flag */