diff options
author | Jon Mason <jdmason@kudzu.us> | 2015-10-04 22:54:22 -0400 |
---|---|---|
committer | Jon Mason <jdmason@kudzu.us> | 2015-11-08 16:11:21 -0500 |
commit | c92ba3c5d97de59c016d1a23ebab17293a792621 (patch) | |
tree | a887ab7f7133b6bce843d3611dc63dba49f0ad8f | |
parent | 70d4687d60184915b6f40920041caa1df4f4d033 (diff) |
NTB: invalid buf pointer in multi-MW setups
Order of operations issue with the QP Num and MW count, which would
result in the receive buffer pointer being invalid if there are more
than 1 MW. Corrected with parenthesis to enforce the proper order of
operations.
Reported-by: John I. Kading <John.Kading@gd-ms.com>
Signed-off-by: Jon Mason <jdmason@kudzu.us>
-rw-r--r-- | drivers/ntb/ntb_transport.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/drivers/ntb/ntb_transport.c b/drivers/ntb/ntb_transport.c index 27b96ae8b191..be9389599e75 100644 --- a/drivers/ntb/ntb_transport.c +++ b/drivers/ntb/ntb_transport.c | |||
@@ -605,7 +605,7 @@ static int ntb_transport_setup_qp_mw(struct ntb_transport_ctx *nt, | |||
605 | num_qps_mw = qp_count / mw_count; | 605 | num_qps_mw = qp_count / mw_count; |
606 | 606 | ||
607 | rx_size = (unsigned int)mw->xlat_size / num_qps_mw; | 607 | rx_size = (unsigned int)mw->xlat_size / num_qps_mw; |
608 | qp->rx_buff = mw->virt_addr + rx_size * qp_num / mw_count; | 608 | qp->rx_buff = mw->virt_addr + rx_size * (qp_num / mw_count); |
609 | rx_size -= sizeof(struct ntb_rx_info); | 609 | rx_size -= sizeof(struct ntb_rx_info); |
610 | 610 | ||
611 | qp->remote_rx_info = qp->rx_buff + rx_size; | 611 | qp->remote_rx_info = qp->rx_buff + rx_size; |
@@ -956,7 +956,7 @@ static int ntb_transport_init_queue(struct ntb_transport_ctx *nt, | |||
956 | mw_size = nt->mw_vec[mw_num].phys_size; | 956 | mw_size = nt->mw_vec[mw_num].phys_size; |
957 | 957 | ||
958 | tx_size = (unsigned int)mw_size / num_qps_mw; | 958 | tx_size = (unsigned int)mw_size / num_qps_mw; |
959 | qp_offset = tx_size * qp_num / mw_count; | 959 | qp_offset = tx_size * (qp_num / mw_count); |
960 | 960 | ||
961 | qp->tx_mw = nt->mw_vec[mw_num].vbase + qp_offset; | 961 | qp->tx_mw = nt->mw_vec[mw_num].vbase + qp_offset; |
962 | if (!qp->tx_mw) | 962 | if (!qp->tx_mw) |