summaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
authorMaciej Grochowski <Maciej.Grochowski@sony.com>2025-02-13 14:53:18 -0800
committerJon Mason <jdmason@kudzu.us>2026-02-20 17:31:55 -0500
commitc8ba7ad2cc1c7b90570aa347b8ebbe279f1eface (patch)
tree2baaf5b41173a8eaf1f1db05e8bb7aaefbfc1d50 /drivers
parent186615f8855a0be4ee7d3fcd09a8ecc10e783b08 (diff)
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>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/ntb/hw/mscc/ntb_hw_switchtec.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/drivers/ntb/hw/mscc/ntb_hw_switchtec.c b/drivers/ntb/hw/mscc/ntb_hw_switchtec.c
index 75809a5d19d9..0536521fa6cc 100644
--- a/drivers/ntb/hw/mscc/ntb_hw_switchtec.c
+++ b/drivers/ntb/hw/mscc/ntb_hw_switchtec.c
@@ -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;
}
}