@@ -1830,6 +1830,8 @@ int ctx_modify_dc_qp_to_init(struct ibv_qp *qp,struct perftest_parameters *user_
if (user_param->duplex || user_param->tst == LAT) {
num_of_qps /= 2;
+ if (num_of_qps < 2)
+ num_of_qps = 2;
num_of_qps_per_port = num_of_qps / 2;
}
@@ -1896,6 +1898,8 @@ int ctx_modify_qp_to_init(struct ibv_qp *qp,struct perftest_parameters *user_par
if ( user_param->use_xrc && (user_param->duplex || user_param->tst == LAT)) {
num_of_qps /= 2;
+ if (num_of_qps < 2)
+ num_of_qps = 2;
num_of_qps_per_port = num_of_qps / 2;
}
Somehow or another, if someone were to feed a 1 into num_of_qps, then we'd have num_of_qps = 1 / 2 = 0, and later on, portindex % 0 -- a divide by zero condition. Make sure that can't happen. This resolves a coverity/clang warning. CC: Gil Rockah <gilr@mellanox.com> Signed-off-by: Jarod Wilson <jarod@redhat.com> --- src/perftest_resources.c | 4 ++++ 1 file changed, 4 insertions(+)