From patchwork Wed May 18 17:44:07 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jarod Wilson X-Patchwork-Id: 9121571 Return-Path: X-Original-To: patchwork-linux-rdma@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 0710DBF29F for ; Wed, 18 May 2016 17:44:24 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id EAB512034B for ; Wed, 18 May 2016 17:44:22 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id AF7C020340 for ; Wed, 18 May 2016 17:44:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753159AbcERRoV (ORCPT ); Wed, 18 May 2016 13:44:21 -0400 Received: from mx1.redhat.com ([209.132.183.28]:47981 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753131AbcERRoU (ORCPT ); Wed, 18 May 2016 13:44:20 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 2DAEFC0578CA; Wed, 18 May 2016 17:44:20 +0000 (UTC) Received: from hp-dl360pgen8-07.khw.lab.eng.bos.redhat.com (hp-dl360pgen8-07.khw.lab.eng.bos.redhat.com [10.16.184.47]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u4IHiCNv017617; Wed, 18 May 2016 13:44:19 -0400 From: Jarod Wilson To: linux-rdma@vger.kernel.org Cc: Jarod Wilson , Gil Rockah Subject: [PATCH perftest] Fix use of uninitialized wc Date: Wed, 18 May 2016 13:44:07 -0400 Message-Id: <1463593448-30864-2-git-send-email-jarod@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Wed, 18 May 2016 17:44:20 +0000 (UTC) Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Spam-Status: No, score=-8.3 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Clang noticed that we may be assigning a garbage/undefined value to wc_id, due to a potentially uninitialized wc. Just memset wc after allocation, and we're all set. 1. perftest-3.0/src/raw_ethernet_resources.c:842:12: warning: Assigned value is garbage or undefined # wc_id = (user_param->verb_type == ACCL_INTF) ? # ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4. perftest-3.0/src/raw_ethernet_resources.c:673:2: note: Uninitialized value stored to field 'wr_id' # ALLOCATE(wc,struct ibv_wc,CTX_POLL_BATCH); # ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 7. perftest-3.0/src/perftest_parameters.h:212:20: note: expanded from macro 'ALLOCATE' # { if((var = (type*)malloc(sizeof(type)*(size))) == NULL) \ # ^~~~~~~~~~~~~~~~~~~~~~~~~~~ 10. perftest-3.0/src/raw_ethernet_resources.c:673:2: note: Taking false branch 11. perftest-3.0/src/perftest_parameters.h:212:3: note: expanded from macro 'ALLOCATE' # { if((var = (type*)malloc(sizeof(type)*(size))) == NULL) \ # ^ 14. perftest-3.0/src/raw_ethernet_resources.c:682:2: note: Taking false branch # if (user_param->noPeak == ON) # ^ 17. perftest-3.0/src/raw_ethernet_resources.c:685:39: note: Left side of '&&' is false # if(user_param->test_type == DURATION && user_param->machine == CLIENT && firstRx) { # ^ 20. perftest-3.0/src/raw_ethernet_resources.c:694:44: note: Left side of '&&' is false # while ((user_param->test_type == DURATION && user_param->state != END_STATE) || totccnt < tot_iters || totrcnt < tot_iters) { # ^ 23. perftest-3.0/src/raw_ethernet_resources.c:694:82: note: Assuming 'totccnt' is < 'tot_iters' # while ((user_param->test_type == DURATION && user_param->state != END_STATE) || totccnt < tot_iters || totrcnt < tot_iters) { # ^~~~~~~~~~~~~~~~~~~ 26. perftest-3.0/src/raw_ethernet_resources.c:694:102: note: Left side of '||' is true # while ((user_param->test_type == DURATION && user_param->state != END_STATE) || totccnt < tot_iters || totrcnt < tot_iters) { # ^ 29. perftest-3.0/src/raw_ethernet_resources.c:696:3: note: Loop condition is false. Execution continues on line 786 # for (index=0; index < user_param->num_of_qps; index++) { # ^ 32. perftest-3.0/src/raw_ethernet_resources.c:786:3: note: Taking false branch # if (user_param->use_event) { # ^ 35. perftest-3.0/src/raw_ethernet_resources.c:795:44: note: Left side of '&&' is false # if ((user_param->test_type == ITERATIONS && (totrcnt < tot_iters)) || (user_param->test_type == DURATION && user_param->state != END_STATE)) { # ^ 38. perftest-3.0/src/raw_ethernet_resources.c:795:108: note: Left side of '&&' is false # if ((user_param->test_type == ITERATIONS && (totrcnt < tot_iters)) || (user_param->test_type == DURATION && user_param->state != END_STATE)) { # ^ 41. perftest-3.0/src/raw_ethernet_resources.c:832:29: note: Left side of '||' is true # if ((totccnt < tot_iters) || (user_param->test_type == DURATION && user_param->state != END_STATE)) { # ^ 44. perftest-3.0/src/raw_ethernet_resources.c:840:8: note: Assuming 'ne' is <= 0 # if (ne > 0) { # ^~~~~~ 47. perftest-3.0/src/raw_ethernet_resources.c:840:4: note: Taking false branch # if (ne > 0) { # ^ 50. perftest-3.0/src/raw_ethernet_resources.c:864:15: note: Assuming 'ne' is >= 0 # } else if (ne < 0) { # ^~~~~~ 53. perftest-3.0/src/raw_ethernet_resources.c:864:11: note: Taking false branch # } else if (ne < 0) { # ^ 56. perftest-3.0/src/raw_ethernet_resources.c:869:4: note: Loop condition is false. Execution continues on line 694 # while (rwqe_sent - totccnt < user_param->rx_depth) { /* Post more than buffer_size */ # ^ 59. perftest-3.0/src/raw_ethernet_resources.c:694:44: note: Left side of '&&' is false # while ((user_param->test_type == DURATION && user_param->state != END_STATE) || totccnt < tot_iters || totrcnt < tot_iters) { # ^ 62. perftest-3.0/src/raw_ethernet_resources.c:694:102: note: Left side of '||' is true # while ((user_param->test_type == DURATION && user_param->state != END_STATE) || totccnt < tot_iters || totrcnt < tot_iters) { # ^ 65. perftest-3.0/src/raw_ethernet_resources.c:696:3: note: Loop condition is false. Execution continues on line 786 # for (index=0; index < user_param->num_of_qps; index++) { # ^ 68. perftest-3.0/src/raw_ethernet_resources.c:786:3: note: Taking false branch # if (user_param->use_event) { # ^ 71. perftest-3.0/src/raw_ethernet_resources.c:795:44: note: Left side of '&&' is false # if ((user_param->test_type == ITERATIONS && (totrcnt < tot_iters)) || (user_param->test_type == DURATION && user_param->state != END_STATE)) { # ^ 74. perftest-3.0/src/raw_ethernet_resources.c:795:108: note: Left side of '&&' is false # if ((user_param->test_type == ITERATIONS && (totrcnt < tot_iters)) || (user_param->test_type == DURATION && user_param->state != END_STATE)) { # ^ 77. perftest-3.0/src/raw_ethernet_resources.c:832:29: note: Left side of '||' is true # if ((totccnt < tot_iters) || (user_param->test_type == DURATION && user_param->state != END_STATE)) { # ^ 80. perftest-3.0/src/raw_ethernet_resources.c:840:8: note: Assuming 'ne' is > 0 # if (ne > 0) { # ^~~~~~ 83. perftest-3.0/src/raw_ethernet_resources.c:840:4: note: Taking true branch # if (ne > 0) { # ^ 86. perftest-3.0/src/raw_ethernet_resources.c:841:5: note: Loop condition is true. Entering loop body # for (i = 0; i < ne; i++) { # ^ 89. perftest-3.0/src/raw_ethernet_resources.c:842:14: note: '?' condition is false # wc_id = (user_param->verb_type == ACCL_INTF) ? # ^ 92. perftest-3.0/src/raw_ethernet_resources.c:842:12: note: Assigned value is garbage or undefined # wc_id = (user_param->verb_type == ACCL_INTF) ? # ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # 840| if (ne > 0) { # 841| for (i = 0; i < ne; i++) { # 842|-> wc_id = (user_param->verb_type == ACCL_INTF) ? # 843| 0 : (int)wc[i].wr_id; # 844| CC: Gil Rockah Signed-off-by: Jarod Wilson --- src/raw_ethernet_resources.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/raw_ethernet_resources.c b/src/raw_ethernet_resources.c index e87654d..534943d 100755 --- a/src/raw_ethernet_resources.c +++ b/src/raw_ethernet_resources.c @@ -696,6 +696,7 @@ int run_iter_fw(struct pingpong_context *ctx,struct perftest_parameters *user_pa ALLOCATE(wc_tx,struct ibv_wc,CTX_POLL_BATCH); ALLOCATE(rcnt_for_qp,uint64_t,user_param->num_of_qps); + memset(wc,0,sizeof(struct ibv_wc)); memset(rcnt_for_qp,0,sizeof(uint64_t)*user_param->num_of_qps); tot_iters = (uint64_t)user_param->iters*user_param->num_of_qps;