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 <maureen.helm@nxp.com>
This commit is contained in:
Maureen Helm 2019-08-29 16:29:39 -05:00 committed by Ioannis Glaropoulos
parent 47f36afdb9
commit aa9b762d12

View file

@ -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 */