Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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>

authored by

Maciej Grochowski and committed by
Jon Mason
c8ba7ad2 186615f8

+6
+6
drivers/ntb/hw/mscc/ntb_hw_switchtec.c
··· 1316 1316 for (i = 0; i < sndev->nr_lut_mw; i++) { 1317 1317 int idx = sndev->nr_direct_mw + i; 1318 1318 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 + 1319 1325 sndev->self_shared->mw_sizes[idx] = LUT_SIZE; 1320 1326 } 1321 1327 }