Skip to content

Commit aa9b762

Browse files
MaureenHelmioannisg
authored andcommitted
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 <[email protected]>
1 parent 47f36af commit aa9b762

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

subsys/disk/disk_access_usdhc.c

+2-1
Original file line numberDiff line numberDiff line change
@@ -1101,7 +1101,8 @@ static int usdhc_cmd_rsp(struct usdhc_priv *priv)
11011101
((cmd->response[i - 2U] &
11021102
0xFF000000U) >> 24U);
11031103
}
1104-
} while (i--);
1104+
i--;
1105+
} while (i);
11051106
}
11061107
}
11071108
/* check response error flag */

0 commit comments

Comments
 (0)