Skip to content

Commit c8ba7ad

Browse files
Maciej Grochowskijonmason
authored andcommitted
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>
1 parent 186615f commit c8ba7ad

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

drivers/ntb/hw/mscc/ntb_hw_switchtec.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1316,6 +1316,12 @@ static void switchtec_ntb_init_shared(struct switchtec_ntb *sndev)
13161316
for (i = 0; i < sndev->nr_lut_mw; i++) {
13171317
int idx = sndev->nr_direct_mw + i;
13181318

1319+
if (idx >= MAX_MWS) {
1320+
dev_err(&sndev->stdev->dev,
1321+
"Total number of MW cannot be bigger than %d", MAX_MWS);
1322+
break;
1323+
}
1324+
13191325
sndev->self_shared->mw_sizes[idx] = LUT_SIZE;
13201326
}
13211327
}

0 commit comments

Comments
 (0)