mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-05-16 06:41:39 -04:00
ntb: ntb_hw_switchtec: Fix array-index-out-of-bounds access
Number of MW LUTs depends on NTB configuration and can be set to MAX_MWS, This patch protects against invalid index out of bounds access to mw_sizes When invalid access print message to user that configuration is not valid. Signed-off-by: Maciej Grochowski <Maciej.Grochowski@sony.com> Signed-off-by: Jon Mason <jdmason@kudzu.us>
This commit is contained in:
committed by
Jon Mason
parent
186615f885
commit
c8ba7ad2cc
@@ -1316,6 +1316,12 @@ static void switchtec_ntb_init_shared(struct switchtec_ntb *sndev)
|
||||
for (i = 0; i < sndev->nr_lut_mw; i++) {
|
||||
int idx = sndev->nr_direct_mw + i;
|
||||
|
||||
if (idx >= MAX_MWS) {
|
||||
dev_err(&sndev->stdev->dev,
|
||||
"Total number of MW cannot be bigger than %d", MAX_MWS);
|
||||
break;
|
||||
}
|
||||
|
||||
sndev->self_shared->mw_sizes[idx] = LUT_SIZE;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user