Skip to content
/ linux Public

Commit 85c9daa

Browse files
Maciej GrochowskiSasha Levin
authored andcommitted
ntb: ntb_hw_switchtec: Fix array-index-out-of-bounds access
[ Upstream commit c8ba7ad ] 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> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent a4557dc commit 85c9daa

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

drivers/ntb/hw/mscc/ntb_hw_switchtec.c

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

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

0 commit comments

Comments
 (0)