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 shift-out-of-bounds for 0 mw lut

Number of MW LUTs depends on NTB configuration and can be set to zero,
in such scenario rounddown_pow_of_two will cause undefined behaviour and
should not be performed.
This patch ensures that rounddown_pow_of_two is called on valid value.

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
186615f8 f39e7d0e

+4 -2
+4 -2
drivers/ntb/hw/mscc/ntb_hw_switchtec.c
··· 1202 1202 sndev->mmio_self_ctrl); 1203 1203 1204 1204 sndev->nr_lut_mw = ioread16(&sndev->mmio_self_ctrl->lut_table_entries); 1205 - sndev->nr_lut_mw = rounddown_pow_of_two(sndev->nr_lut_mw); 1205 + if (sndev->nr_lut_mw) 1206 + sndev->nr_lut_mw = rounddown_pow_of_two(sndev->nr_lut_mw); 1206 1207 1207 1208 dev_dbg(&sndev->stdev->dev, "MWs: %d direct, %d lut\n", 1208 1209 sndev->nr_direct_mw, sndev->nr_lut_mw); ··· 1213 1212 1214 1213 sndev->peer_nr_lut_mw = 1215 1214 ioread16(&sndev->mmio_peer_ctrl->lut_table_entries); 1216 - sndev->peer_nr_lut_mw = rounddown_pow_of_two(sndev->peer_nr_lut_mw); 1215 + if (sndev->peer_nr_lut_mw) 1216 + sndev->peer_nr_lut_mw = rounddown_pow_of_two(sndev->peer_nr_lut_mw); 1217 1217 1218 1218 dev_dbg(&sndev->stdev->dev, "Peer MWs: %d direct, %d lut\n", 1219 1219 sndev->peer_nr_direct_mw, sndev->peer_nr_lut_mw);