From patchwork Wed Jan 2 13:12:56 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Honggang LI X-Patchwork-Id: 10746323 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 7674B746 for ; Wed, 2 Jan 2019 13:13:45 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6428420587 for ; Wed, 2 Jan 2019 13:13:45 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 549C626E96; Wed, 2 Jan 2019 13:13:45 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E1D992875C for ; Wed, 2 Jan 2019 13:13:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729437AbfABNNo (ORCPT ); Wed, 2 Jan 2019 08:13:44 -0500 Received: from mx1.redhat.com ([209.132.183.28]:60316 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726939AbfABNNo (ORCPT ); Wed, 2 Jan 2019 08:13:44 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 44FB680F95; Wed, 2 Jan 2019 13:13:44 +0000 (UTC) Received: from localhost (ovpn-12-97.pek2.redhat.com [10.72.12.97]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 983B41001947; Wed, 2 Jan 2019 13:13:43 +0000 (UTC) From: Honggang Li To: hal@dev.mellanox.co.il Cc: linux-rdma@vger.kernel.org, Honggang Li Subject: [ibsim patch 01/23] move sim_cmd_file into ibsim/sim_cmd.c Date: Wed, 2 Jan 2019 21:12:56 +0800 Message-Id: <20190102131318.5765-1-honli@redhat.com> X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Wed, 02 Jan 2019 13:13:44 +0000 (UTC) Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The 'sim_cmd_file' function only called by 'do_cmd' function in the sim_cmd.c file. Signed-off-by: Honggang Li --- ibsim/ibsim.c | 38 -------------------------------------- ibsim/sim_cmd.c | 38 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+), 38 deletions(-) diff --git a/ibsim/ibsim.c b/ibsim/ibsim.c index debf591fea92..40e605c75429 100644 --- a/ibsim/ibsim.c +++ b/ibsim/ibsim.c @@ -517,44 +517,6 @@ static int sim_read_pkt(int fd, int client) return -1; // never reached } -int sim_cmd_file(FILE * f, char *s) -{ - char line[4096]; - FILE *cmd_file; - char *p; - - s++; - while (isspace(*s)) - s++; - - if (!s || !*s) { - fprintf(f, "do_cmd_from_file: no file name - skip\n"); - return -1; - } - - p = s + strlen(s) - 1; - while (isspace(*p)) { - *p = '\0'; - p--; - } - - cmd_file = fopen(s, "r"); - if (!cmd_file) { - fprintf(f, "do_cmd_from_file: cannot open file \'%s\': %s\n", - s, strerror(errno)); - return -1; - } - - while (fgets(line, sizeof(line) - 1, cmd_file) != NULL) { - if((p = strchr(line, '\n')) != NULL) - *p = '\0'; - do_cmd(line, f); - } - - fclose(cmd_file); - return 0; -} - static int sim_init_net(char *netconf, FILE * out) { DEBUG("reading %s", netconf); diff --git a/ibsim/sim_cmd.c b/ibsim/sim_cmd.c index 4b8fb62e0906..4345731e5081 100644 --- a/ibsim/sim_cmd.c +++ b/ibsim/sim_cmd.c @@ -1143,6 +1143,44 @@ format_error: return -1; } +int sim_cmd_file(FILE * f, char *s) +{ + char line[4096]; + FILE *cmd_file; + char *p; + + s++; + while (isspace(*s)) + s++; + + if (!s || !*s) { + fprintf(f, "do_cmd_from_file: no file name - skip\n"); + return -1; + } + + p = s + strlen(s) - 1; + while (isspace(*p)) { + *p = '\0'; + p--; + } + + cmd_file = fopen(s, "r"); + if (!cmd_file) { + fprintf(f, "do_cmd_from_file: cannot open file \'%s\': %s\n", + s, strerror(errno)); + return -1; + } + + while (fgets(line, sizeof(line) - 1, cmd_file) != NULL) { + if((p = strchr(line, '\n')) != NULL) + *p = '\0'; + do_cmd(line, f); + } + + fclose(cmd_file); + return 0; +} + int netstarted; int do_cmd(char *buf, FILE *f) From patchwork Wed Jan 2 13:12:57 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Honggang LI X-Patchwork-Id: 10746325 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 084F1746 for ; Wed, 2 Jan 2019 13:13:49 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id ECCC720587 for ; Wed, 2 Jan 2019 13:13:48 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DFFD927528; Wed, 2 Jan 2019 13:13:48 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8A75B20587 for ; Wed, 2 Jan 2019 13:13:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729450AbfABNNs (ORCPT ); Wed, 2 Jan 2019 08:13:48 -0500 Received: from mx1.redhat.com ([209.132.183.28]:35958 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726939AbfABNNs (ORCPT ); Wed, 2 Jan 2019 08:13:48 -0500 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id EC08680495; Wed, 2 Jan 2019 13:13:47 +0000 (UTC) Received: from localhost (ovpn-12-97.pek2.redhat.com [10.72.12.97]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 4A82060123; Wed, 2 Jan 2019 13:13:46 +0000 (UTC) From: Honggang Li To: hal@dev.mellanox.co.il Cc: linux-rdma@vger.kernel.org, Honggang Li Subject: [ibsim patch 02/23] Make gcc don't warn about deprecated declarations Date: Wed, 2 Jan 2019 21:12:57 +0800 Message-Id: <20190102131318.5765-2-honli@redhat.com> In-Reply-To: <20190102131318.5765-1-honli@redhat.com> References: <20190102131318.5765-1-honli@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Wed, 02 Jan 2019 13:13:48 +0000 (UTC) Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Signed-off-by: Honggang Li --- defs.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/defs.mk b/defs.mk index 11256c0f0078..4a34f8543861 100644 --- a/defs.mk +++ b/defs.mk @@ -24,7 +24,7 @@ else LIBS:= -L$(libpath) -libmad -libumad endif -CFLAGS += -Wall -g -fpic -I. -I../include $(INCS) +CFLAGS += -Wall -g -Werror -Wno-deprecated-declarations -fpic -I. -I../include $(INCS) LDFLAGS+= -fpic srcs?=$(wildcard *.c) From patchwork Wed Jan 2 13:12:58 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Honggang LI X-Patchwork-Id: 10746327 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 904E9746 for ; Wed, 2 Jan 2019 13:13:53 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 80AE927528 for ; Wed, 2 Jan 2019 13:13:53 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 753DD28450; Wed, 2 Jan 2019 13:13:53 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DE95E27528 for ; Wed, 2 Jan 2019 13:13:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729893AbfABNNw (ORCPT ); Wed, 2 Jan 2019 08:13:52 -0500 Received: from mx1.redhat.com ([209.132.183.28]:35494 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726939AbfABNNw (ORCPT ); Wed, 2 Jan 2019 08:13:52 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id E34FCCD65D; Wed, 2 Jan 2019 13:13:51 +0000 (UTC) Received: from localhost (ovpn-12-97.pek2.redhat.com [10.72.12.97]) by smtp.corp.redhat.com (Postfix) with ESMTPS id EE1945D9C5; Wed, 2 Jan 2019 13:13:50 +0000 (UTC) From: Honggang Li To: hal@dev.mellanox.co.il Cc: linux-rdma@vger.kernel.org, Honggang Li Subject: [ibsim patch 03/23] ibsim: return 'NULL' instead of '0' if fucntion return a pointer Date: Wed, 2 Jan 2019 21:12:58 +0800 Message-Id: <20190102131318.5765-3-honli@redhat.com> In-Reply-To: <20190102131318.5765-1-honli@redhat.com> References: <20190102131318.5765-1-honli@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Wed, 02 Jan 2019 13:13:51 +0000 (UTC) Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Signed-off-by: Honggang Li --- ibsim/ibsim.c | 2 +- ibsim/sim_cmd.c | 2 +- ibsim/sim_mad.c | 18 +++++++++--------- ibsim/sim_net.c | 32 ++++++++++++++++---------------- 4 files changed, 27 insertions(+), 27 deletions(-) diff --git a/ibsim/ibsim.c b/ibsim/ibsim.c index 40e605c75429..4e01f55f1817 100644 --- a/ibsim/ibsim.c +++ b/ibsim/ibsim.c @@ -664,7 +664,7 @@ Client *find_client(Port * port, int response, int qp, uint64_t trid) return cl; } DEBUG("no client found"); - return 0; + return NULL; } void usage(char *prog_name) diff --git a/ibsim/sim_cmd.c b/ibsim/sim_cmd.c index 4345731e5081..92343525645b 100644 --- a/ibsim/sim_cmd.c +++ b/ibsim/sim_cmd.c @@ -633,7 +633,7 @@ static Port *find_port(int lid) } if (port && (port->lid + (1 << port->lmc)) > lid) return port; - return 0; + return NULL; } static int do_change_baselid(FILE * f, char *line) diff --git a/ibsim/sim_mad.c b/ibsim/sim_mad.c index 0312c05f2e34..edb23952b47a 100644 --- a/ibsim/sim_mad.c +++ b/ibsim/sim_mad.c @@ -1639,7 +1639,7 @@ static Port *lid_route_MAD(Port * port, int lid) if (lid == 0) { IBWARN("invalid lid 0"); - return 0; + return NULL; } if (is_port_lid(port, lid)) @@ -1649,11 +1649,11 @@ static Port *lid_route_MAD(Port * port, int lid) pc_add_error_xmitdiscards(port); IBWARN("failed: disconnected node 0x%" PRIx64 " or port 0x%" PRIx64 "?", node->nodeguid, port->portguid); - return 0; + return NULL; } if (!pc_updated(&tport, port)) // if Client connected via HCA ... - return 0; + return NULL; for (hop = 0; !is_port_lid(port, lid) && hop < MAXHOPS; hop++) { portnum = switch_lookup(node, lid); @@ -1662,7 +1662,7 @@ static Port *lid_route_MAD(Port * port, int lid) pc_add_error_rcvswitchrelay(port); DEBUG("illegal lid %u (outport %d node %s ports %d)", lid, portnum, node->nodeid, node->numports); - return 0; + return NULL; } DEBUG("node %" PRIx64 " outport %d", node->nodeguid, portnum); @@ -1676,7 +1676,7 @@ static Port *lid_route_MAD(Port * port, int lid) if (!link_valid(port)) { pc_add_error_xmitdiscards(port); - return 0; + return NULL; } tport = port; // prepare to pass PKT to next port @@ -1687,7 +1687,7 @@ static Port *lid_route_MAD(Port * port, int lid) if (port_get_remote(port, &node, &port) < 0) { pc_add_error_xmitdiscards(tport); IBWARN("no remote"); - return 0; + return NULL; } if (!node || !port) // double check ?... @@ -1695,11 +1695,11 @@ static Port *lid_route_MAD(Port * port, int lid) if (!link_valid(port)) { pc_add_error_xmitdiscards(tport); - return 0; + return NULL; } if (!pc_updated(&tport, port)) //try to transmit PKT - return 0; + return NULL; } DEBUG("routed to node %s port 0x%" PRIx64 " portnum %d (%p)", @@ -1818,7 +1818,7 @@ static Smpfn *get_handle_fn(ib_rpc_t rpc, int response) Smpfn *fn; if (response) - return 0; + return NULL; fn = get_smp_handler(rpc.mgtclass & 0xf , rpc.attr.id); return fn; diff --git a/ibsim/sim_net.c b/ibsim/sim_net.c index 8695815d9a74..a963ff6d6589 100644 --- a/ibsim/sim_net.c +++ b/ibsim/sim_net.c @@ -251,7 +251,7 @@ static Switch *new_switch(Node * nd, int set_esp0) if (netswitches >= maxnetswitches) { IBPANIC("no more switches (max %d)", maxnetswitches); - return 0; + return NULL; } sw = switches + netswitches++; @@ -304,22 +304,22 @@ static Node *new_node(int type, char *nodename, char *nodedesc, int nodeports) Node *nd; if (build_nodeid(nodeid, sizeof(nodeid), nodename) < 0) - return 0; + return NULL; if (find_node(nodeid)) { IBWARN("node id %s already exists", nodeid); - return 0; + return NULL; } if (netnodes >= maxnetnodes) { IBPANIC("no more nodes (max %d)", maxnetnodes); - return 0; + return NULL; } if (find_node_by_guid(guids[type])) { IBWARN("node %s guid %" PRIx64 " already exists", node_type_name(type), guids[type]); - return 0; + return NULL; } nd = nodes + netnodes++; @@ -354,7 +354,7 @@ static Node *new_node(int type, char *nodename, char *nodedesc, int nodeports) if ((nd->portsbase = new_ports(nd, nodeports, firstport)) < 0) { IBWARN("can't alloc %d ports for node %s", nodeports, nd->nodeid); - return 0; + return NULL; } netvendid = 0; @@ -376,7 +376,7 @@ static char *parse_node_id(char *buf, char **rest_buf) if (!(s = strchr(buf, '"')) || !(e = strchr(s + 1, '"'))) { IBWARN("can't find valid id in <%s>", buf); - return 0; + return NULL; } *e = 0; if (rest_buf) @@ -678,7 +678,7 @@ char *map_alias(char *alias) if (aliases[i][len] == '#') return aliases[i] + len + 1; } - return 0; + return NULL; } char *expand_name(char *base, char *name, char **portstr) @@ -686,7 +686,7 @@ char *expand_name(char *base, char *name, char **portstr) char *s; if (!base) - return 0; + return NULL; if (!strchr(base, '@')) { if (netprefix[0] != 0 && !strchr(base, '#')) @@ -703,7 +703,7 @@ char *expand_name(char *base, char *name, char **portstr) PDEBUG("alias %s", name); if (!(s = map_alias(name))) - return 0; + return NULL; strncpy(name, s, NODEIDLEN - 1); @@ -1481,13 +1481,13 @@ Node *find_node(char *desc) Node *nd, *e; if (!desc) - return 0; + return NULL; for (nd = nodes, e = nodes + netnodes; nd < e; nd++) if (!strcmp(desc, nd->nodeid)) return nd; - return 0; + return NULL; } Node *find_node_by_desc(char *desc) @@ -1495,13 +1495,13 @@ Node *find_node_by_desc(char *desc) Node *nd, *e; if (!desc) - return 0; + return NULL; for (nd = nodes, e = nodes + netnodes; nd < e; nd++) if (!strcmp(desc, nd->nodedesc)) return nd; - return 0; + return NULL; } Node *find_node_by_guid(uint64_t guid) @@ -1509,13 +1509,13 @@ Node *find_node_by_guid(uint64_t guid) Node *nd, *e; if (ignoreduplicate) - return 0; + return NULL; for (nd = nodes, e = nodes + netnodes; nd < e; nd++) if (nd->nodeguid == guid) return nd; - return 0; + return NULL; } Port *node_get_port(Node * node, int portnum) From patchwork Wed Jan 2 13:12:59 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Honggang LI X-Patchwork-Id: 10746329 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 6CC1191E for ; Wed, 2 Jan 2019 13:13:56 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5DDA827528 for ; Wed, 2 Jan 2019 13:13:56 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4F74D28450; Wed, 2 Jan 2019 13:13:56 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E506F27528 for ; Wed, 2 Jan 2019 13:13:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729895AbfABNNz (ORCPT ); Wed, 2 Jan 2019 08:13:55 -0500 Received: from mx1.redhat.com ([209.132.183.28]:53192 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726939AbfABNNz (ORCPT ); Wed, 2 Jan 2019 08:13:55 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 910EC550CF; Wed, 2 Jan 2019 13:13:55 +0000 (UTC) Received: from localhost (ovpn-12-97.pek2.redhat.com [10.72.12.97]) by smtp.corp.redhat.com (Postfix) with ESMTPS id E56B25D75C; Wed, 2 Jan 2019 13:13:54 +0000 (UTC) From: Honggang Li To: hal@dev.mellanox.co.il Cc: linux-rdma@vger.kernel.org, Honggang Li Subject: [ibsim patch 04/23] sim_net.c: avoid copy garbage Date: Wed, 2 Jan 2019 21:12:59 +0800 Message-Id: <20190102131318.5765-4-honli@redhat.com> In-Reply-To: <20190102131318.5765-1-honli@redhat.com> References: <20190102131318.5765-1-honli@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Wed, 02 Jan 2019 13:13:55 +0000 (UTC) Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The sizeof(port->vlarb_high) is 128. sizeof(default_vlarb_high) is 30. memcpy(port->vlarb_high, default_vlarb_high, sizeof(port->vlarb_high)) will fill [31, 128] bytes of port->vlarb_high with garbage after default_vlarb_high. ------------------------------------------------------------------------- make[1]: Entering directory '/home/honli/rpmbuild/BUILD/ibsim-0.7/ibsim' cc -O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -Wall -g -Werror -Wno-deprecated-declarations -fpic -I. -I../include -I/usr/include -c -o sim_net.o sim_net.c In file included from /usr/include/string.h:494, from sim_net.c:38: In function 'memcpy', inlined from 'init_ports' at sim_net.c:648:3: /usr/include/bits/string_fortified.h:34:10: error: '__builtin_memcpy' forming offset [31, 128] is out of the bounds [0, 30] of object 'default_vlarb_high' with type 'const struct vlarb[15]' [-Werror=array-bounds] return __builtin___memcpy_chk (__dest, __src, __len, __bos0 (__dest)); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ sim_net.c: In function 'init_ports': sim_net.c:171:27: note: 'default_vlarb_high' declared here static const struct vlarb default_vlarb_high[] = { ^~~~~~~~~~~~~~~~~~ In file included from /usr/include/string.h:494, from sim_net.c:38: In function 'memcpy', inlined from 'init_ports' at sim_net.c:650:3: /usr/include/bits/string_fortified.h:34:10: error: '__builtin_memcpy' forming offset [31, 128] is out of the bounds [0, 30] of object 'default_vlarb_low' with type 'const struct vlarb[15]' [-Werror=array-bounds] return __builtin___memcpy_chk (__dest, __src, __len, __bos0 (__dest)); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ sim_net.c: In function 'init_ports': sim_net.c:176:27: note: 'default_vlarb_low' declared here static const struct vlarb default_vlarb_low[] = { ^~~~~~~~~~~~~~~~~ In file included from /usr/include/string.h:494, from sim_net.c:38: Signed-off-by: Honggang Li --- ibsim/sim_net.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ibsim/sim_net.c b/ibsim/sim_net.c index a963ff6d6589..a62d39d39174 100644 --- a/ibsim/sim_net.c +++ b/ibsim/sim_net.c @@ -646,9 +646,9 @@ static void init_ports(Node * node, int type, int maxports) memcpy(port->sl2vl + 8 * j, default_sl2vl, 8); memcpy(port->vlarb_high, default_vlarb_high, - sizeof(port->vlarb_high)); + sizeof(default_vlarb_high)); memcpy(port->vlarb_low, default_vlarb_low, - sizeof(port->vlarb_low)); + sizeof(default_vlarb_low)); } } From patchwork Wed Jan 2 13:13:00 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Honggang LI X-Patchwork-Id: 10746331 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 19C6A91E for ; Wed, 2 Jan 2019 13:14:00 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 08CDA28450 for ; Wed, 2 Jan 2019 13:14:00 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id F0FE6285A3; Wed, 2 Jan 2019 13:13:59 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9976528450 for ; Wed, 2 Jan 2019 13:13:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729897AbfABNN7 (ORCPT ); Wed, 2 Jan 2019 08:13:59 -0500 Received: from mx1.redhat.com ([209.132.183.28]:42546 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726939AbfABNN7 (ORCPT ); Wed, 2 Jan 2019 08:13:59 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 425279D43E; Wed, 2 Jan 2019 13:13:59 +0000 (UTC) Received: from localhost (ovpn-12-97.pek2.redhat.com [10.72.12.97]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 9639E608DC; Wed, 2 Jan 2019 13:13:58 +0000 (UTC) From: Honggang Li To: hal@dev.mellanox.co.il Cc: linux-rdma@vger.kernel.org, Honggang Li Subject: [ibsim patch 05/23] =?utf-8?b?c2ltX2NtZC5jOiBmaXgg4oCYb3JpZ+KAmSBt?= =?utf-8?b?YXkgYmUgdXNlZCB1bmluaXRpYWxpemVk?= Date: Wed, 2 Jan 2019 21:13:00 +0800 Message-Id: <20190102131318.5765-5-honli@redhat.com> In-Reply-To: <20190102131318.5765-1-honli@redhat.com> References: <20190102131318.5765-1-honli@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Wed, 02 Jan 2019 13:13:59 +0000 (UTC) Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP cc -O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mtune=generic -fasynchronous-unwind-tables -Wall -g -Werror -Wno-deprecated-declarations -fpic -I. -I../include -I/usr/include -c -o sim_cmd.o sim_cmd.c sim_cmd.c: In function ‘do_cmd’: sim_cmd.c:911:11: error: ‘orig’ may be used uninitialized in this function [-Werror=maybe-uninitialized] nodeid = expand_name(orig, name, &sp); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~ sim_cmd.c:897:19: note: ‘orig’ was declared here char *s = line, *orig, *sp, *nodeid, *attr, *field, *field_trim, *end_ptr; Signed-off-by: Honggang Li --- ibsim/sim_cmd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ibsim/sim_cmd.c b/ibsim/sim_cmd.c index 92343525645b..fa5ff9baea6b 100644 --- a/ibsim/sim_cmd.c +++ b/ibsim/sim_cmd.c @@ -894,7 +894,7 @@ static int parse_vl_num(char *attr, char *field, int *vl) static int do_perf_counter_set(FILE *f, char *line) { - char *s = line, *orig, *sp, *nodeid, *attr, *field, *field_trim, *end_ptr; + char *s = line, *orig = NULL, *sp, *nodeid, *attr, *field, *field_trim, *end_ptr; Node *node; int portnum, vl; uint64_t value; From patchwork Wed Jan 2 13:13:01 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Honggang LI X-Patchwork-Id: 10746333 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id BDAA5746 for ; Wed, 2 Jan 2019 13:14:03 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AD4AC284A5 for ; Wed, 2 Jan 2019 13:14:03 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A19E7285FB; Wed, 2 Jan 2019 13:14:03 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5C6C1284A5 for ; Wed, 2 Jan 2019 13:14:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729899AbfABNOD (ORCPT ); Wed, 2 Jan 2019 08:14:03 -0500 Received: from mx1.redhat.com ([209.132.183.28]:50152 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726939AbfABNOD (ORCPT ); Wed, 2 Jan 2019 08:14:03 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id ED5007E9FB; Wed, 2 Jan 2019 13:14:02 +0000 (UTC) Received: from localhost (ovpn-12-97.pek2.redhat.com [10.72.12.97]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 43C845D757; Wed, 2 Jan 2019 13:14:01 +0000 (UTC) From: Honggang Li To: hal@dev.mellanox.co.il Cc: linux-rdma@vger.kernel.org, Honggang Li Subject: [ibsim patch 06/23] sim_mad.c: fix a clang compilation error Date: Wed, 2 Jan 2019 21:13:01 +0800 Message-Id: <20190102131318.5765-6-honli@redhat.com> In-Reply-To: <20190102131318.5765-1-honli@redhat.com> References: <20190102131318.5765-1-honli@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Wed, 02 Jan 2019 13:14:03 +0000 (UTC) Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP sim_mad.c:160:13: error: use of GNU 'missing =' extension in designator [-Werror,-Wgnu-designator] [TRAP_128] encode_trap128, ^ = sim_mad.c:161:13: error: use of GNU 'missing =' extension in designator [-Werror,-Wgnu-designator] [TRAP_144] encode_trap144, ^ = sim_mad.c:163:18: error: use of GNU 'missing =' extension in designator [-Werror,-Wgnu-designator] [TRAP_NUM_LAST] 0, ^ = Signed-off-by: Honggang Li --- ibsim/sim_mad.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ibsim/sim_mad.c b/ibsim/sim_mad.c index edb23952b47a..1660b84dbe4b 100644 --- a/ibsim/sim_mad.c +++ b/ibsim/sim_mad.c @@ -157,10 +157,10 @@ static Smpfn * get_smp_handler(unsigned class_id, unsigned attr_id) } static EncodeTrapfn *encodetrap[] = { - [TRAP_128] encode_trap128, - [TRAP_144] encode_trap144, + [TRAP_128] = encode_trap128, + [TRAP_144] = encode_trap144, - [TRAP_NUM_LAST] 0, + [TRAP_NUM_LAST] = 0, }; extern Node *nodes; From patchwork Wed Jan 2 13:13:02 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Honggang LI X-Patchwork-Id: 10746335 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 6657F91E for ; Wed, 2 Jan 2019 13:14:07 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 55F1027528 for ; Wed, 2 Jan 2019 13:14:07 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 493FB285A3; Wed, 2 Jan 2019 13:14:07 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 02EF227528 for ; Wed, 2 Jan 2019 13:14:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729450AbfABNOG (ORCPT ); Wed, 2 Jan 2019 08:14:06 -0500 Received: from mx1.redhat.com ([209.132.183.28]:60456 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726939AbfABNOG (ORCPT ); Wed, 2 Jan 2019 08:14:06 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 9F50E80F75; Wed, 2 Jan 2019 13:14:06 +0000 (UTC) Received: from localhost (ovpn-12-97.pek2.redhat.com [10.72.12.97]) by smtp.corp.redhat.com (Postfix) with ESMTPS id F25DF1001947; Wed, 2 Jan 2019 13:14:05 +0000 (UTC) From: Honggang Li To: hal@dev.mellanox.co.il Cc: linux-rdma@vger.kernel.org, Honggang Li Subject: [ibsim patch 07/23] run_opensm.sh: remove opensm '-c' option Date: Wed, 2 Jan 2019 21:13:02 +0800 Message-Id: <20190102131318.5765-7-honli@redhat.com> In-Reply-To: <20190102131318.5765-1-honli@redhat.com> References: <20190102131318.5765-1-honli@redhat.com> X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Wed, 02 Jan 2019 13:14:06 +0000 (UTC) Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The '-c' option needs a configuration file. Signed-off-by: Honggang Li --- scripts/run_opensm.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/run_opensm.sh b/scripts/run_opensm.sh index a225d81f17a3..5fd29b5b94f3 100755 --- a/scripts/run_opensm.sh +++ b/scripts/run_opensm.sh @@ -7,7 +7,7 @@ fi if [ -z "$1" ] ; then cmd=opensm - cmd_args="-e -c -V -f ./osm.log -s 0" + cmd_args="-e -V -f ./osm.log -s 0" else cmd="$1" shift From patchwork Wed Jan 2 13:13:03 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Honggang LI X-Patchwork-Id: 10746337 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 5DE36746 for ; Wed, 2 Jan 2019 13:14:11 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4DE272863B for ; Wed, 2 Jan 2019 13:14:11 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 41F47286D5; Wed, 2 Jan 2019 13:14:11 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C142F2863B for ; Wed, 2 Jan 2019 13:14:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729901AbfABNOK (ORCPT ); Wed, 2 Jan 2019 08:14:10 -0500 Received: from mx1.redhat.com ([209.132.183.28]:40482 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729893AbfABNOK (ORCPT ); Wed, 2 Jan 2019 08:14:10 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 57DEF2D7F2; Wed, 2 Jan 2019 13:14:10 +0000 (UTC) Received: from localhost (ovpn-12-97.pek2.redhat.com [10.72.12.97]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 9E2405D75E; Wed, 2 Jan 2019 13:14:09 +0000 (UTC) From: Honggang Li To: hal@dev.mellanox.co.il Cc: linux-rdma@vger.kernel.org, Honggang Li Subject: [ibsim patch 08/23] ibsim.spec.in: Append gcc into the BuildRequires tag Date: Wed, 2 Jan 2019 21:13:03 +0800 Message-Id: <20190102131318.5765-8-honli@redhat.com> In-Reply-To: <20190102131318.5765-1-honli@redhat.com> References: <20190102131318.5765-1-honli@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Wed, 02 Jan 2019 13:14:10 +0000 (UTC) Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP As gcc is no longer the default compiler for Fedora, add 'gcc' as BuildRequirres. Signed-off-by: Honggang Li --- ibsim.spec.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ibsim.spec.in b/ibsim.spec.in index d6ec8987b32a..424b2e01ed60 100644 --- a/ibsim.spec.in +++ b/ibsim.spec.in @@ -11,7 +11,7 @@ Group: System Environment/Libraries BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) Source: http://www.openfabrics.org/downloads/management/@TARBALL@ Url: http://openfabrics.org/ -BuildRequires: libibmad-devel, libibumad-devel +BuildRequires: libibmad-devel, libibumad-devel, gcc %description ibsim provides simulation of infiniband fabric for using with OFA OpenSM, diagnostic and management tools. From patchwork Wed Jan 2 13:13:04 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Honggang LI X-Patchwork-Id: 10746339 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C7651746 for ; Wed, 2 Jan 2019 13:14:14 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B79E22863B for ; Wed, 2 Jan 2019 13:14:14 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id AC214286D5; Wed, 2 Jan 2019 13:14:14 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5527C2863B for ; Wed, 2 Jan 2019 13:14:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729897AbfABNOO (ORCPT ); Wed, 2 Jan 2019 08:14:14 -0500 Received: from mx1.redhat.com ([209.132.183.28]:36126 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726939AbfABNOO (ORCPT ); Wed, 2 Jan 2019 08:14:14 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id F11FD80461; Wed, 2 Jan 2019 13:14:13 +0000 (UTC) Received: from localhost (ovpn-12-97.pek2.redhat.com [10.72.12.97]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 4EFAE608DD; Wed, 2 Jan 2019 13:14:13 +0000 (UTC) From: Honggang Li To: hal@dev.mellanox.co.il Cc: linux-rdma@vger.kernel.org, Honggang Li Subject: [ibsim patch 09/23] sim_net.c: Delete function 'new_hca' Date: Wed, 2 Jan 2019 21:13:04 +0800 Message-Id: <20190102131318.5765-9-honli@redhat.com> In-Reply-To: <20190102131318.5765-1-honli@redhat.com> References: <20190102131318.5765-1-honli@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Wed, 02 Jan 2019 13:14:14 +0000 (UTC) Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Signed-off-by: Honggang Li --- ibsim/sim_net.c | 8 -------- 1 file changed, 8 deletions(-) diff --git a/ibsim/sim_net.c b/ibsim/sim_net.c index a62d39d39174..8f285e6d8f1a 100644 --- a/ibsim/sim_net.c +++ b/ibsim/sim_net.c @@ -279,11 +279,6 @@ static Switch *new_switch(Node * nd, int set_esp0) return sw; } -static int new_hca(Node * nd) -{ - return 0; -} - static int build_nodeid(char *nodeid, size_t len, char *base) { if (strchr(base, '#') || strchr(base, '@')) { @@ -870,9 +865,6 @@ static int parse_endnode(int fd, char *line, int type) if (!(nd = new_node(type, nodeid, nodedesc, ports))) return 0; - if (new_hca(nd) < 0) - return 0; - r = parse_ports(fd, nd, type, ports); PDEBUG("%d ports found", r); From patchwork Wed Jan 2 13:13:05 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Honggang LI X-Patchwork-Id: 10746341 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 71DF991E for ; Wed, 2 Jan 2019 13:14:18 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 622D428813 for ; Wed, 2 Jan 2019 13:14:18 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 56AC82884B; Wed, 2 Jan 2019 13:14:18 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 03A4E28813 for ; Wed, 2 Jan 2019 13:14:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729902AbfABNOR (ORCPT ); Wed, 2 Jan 2019 08:14:17 -0500 Received: from mx1.redhat.com ([209.132.183.28]:35698 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726939AbfABNOR (ORCPT ); Wed, 2 Jan 2019 08:14:17 -0500 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 9C8A465855; Wed, 2 Jan 2019 13:14:17 +0000 (UTC) Received: from localhost (ovpn-12-97.pek2.redhat.com [10.72.12.97]) by smtp.corp.redhat.com (Postfix) with ESMTPS id F0B6660123; Wed, 2 Jan 2019 13:14:16 +0000 (UTC) From: Honggang Li To: hal@dev.mellanox.co.il Cc: linux-rdma@vger.kernel.org, Honggang Li Subject: [ibsim patch 10/23] sim_cmd.c: do_set_guid should dereference the char pointer Date: Wed, 2 Jan 2019 21:13:05 +0800 Message-Id: <20190102131318.5765-10-honli@redhat.com> In-Reply-To: <20190102131318.5765-1-honli@redhat.com> References: <20190102131318.5765-1-honli@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Wed, 02 Jan 2019 13:14:17 +0000 (UTC) Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Signed-off-by: Honggang Li --- ibsim/sim_cmd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ibsim/sim_cmd.c b/ibsim/sim_cmd.c index fa5ff9baea6b..e2fe6ba6dddb 100644 --- a/ibsim/sim_cmd.c +++ b/ibsim/sim_cmd.c @@ -494,7 +494,7 @@ static int do_set_guid(FILE * f, char *line) while (isspace(*s)) s++; - if (!s) + if (!*s) return 0; new_guid = strtoull(s, &end, 0); From patchwork Wed Jan 2 13:13:06 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Honggang LI X-Patchwork-Id: 10746343 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 19401746 for ; Wed, 2 Jan 2019 13:14:22 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F368F28813 for ; Wed, 2 Jan 2019 13:14:21 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E7F512884B; Wed, 2 Jan 2019 13:14:21 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A3C2628813 for ; Wed, 2 Jan 2019 13:14:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729905AbfABNOV (ORCPT ); Wed, 2 Jan 2019 08:14:21 -0500 Received: from mx1.redhat.com ([209.132.183.28]:55586 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729450AbfABNOV (ORCPT ); Wed, 2 Jan 2019 08:14:21 -0500 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 4A7CBC04AC54; Wed, 2 Jan 2019 13:14:21 +0000 (UTC) Received: from localhost (ovpn-12-97.pek2.redhat.com [10.72.12.97]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 9D2B319936; Wed, 2 Jan 2019 13:14:20 +0000 (UTC) From: Honggang Li To: hal@dev.mellanox.co.il Cc: linux-rdma@vger.kernel.org, Honggang Li Subject: [ibsim patch 11/23] sim_cmd.c: fix CONSTANT_EXPRESSION_RESULT for dump_route Date: Wed, 2 Jan 2019 21:13:06 +0800 Message-Id: <20190102131318.5765-11-honli@redhat.com> In-Reply-To: <20190102131318.5765-1-honli@redhat.com> References: <20190102131318.5765-1-honli@redhat.com> X-Scanned-By: MIMEDefang 2.84 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, 02 Jan 2019 13:14:21 +0000 (UTC) Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP node->sw->fdb[to] is uint8_t. So, (node->sw->fdb[to] < 0) is always false. Issue was detected by Coverity. Signed-off-by: Honggang Li --- ibsim/sim_cmd.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ibsim/sim_cmd.c b/ibsim/sim_cmd.c index e2fe6ba6dddb..1d36c600814f 100644 --- a/ibsim/sim_cmd.c +++ b/ibsim/sim_cmd.c @@ -751,8 +751,8 @@ static int dump_route(FILE * f, char *line) break; // found outport = portnum; if (node->type == SWITCH_NODE) { - if ((outport = node->sw->fdb[to]) < 0 - || to > node->sw->linearFDBtop) + outport = node->sw->fdb[to]; + if (to > node->sw->linearFDBtop) goto badtbl; port = ports + node->portsbase + outport; if (outport == 0) { From patchwork Wed Jan 2 13:13:07 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Honggang LI X-Patchwork-Id: 10746345 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id AA97591E for ; Wed, 2 Jan 2019 13:14:25 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9B43B28813 for ; Wed, 2 Jan 2019 13:14:25 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8F9222884B; Wed, 2 Jan 2019 13:14:25 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4EE2A28813 for ; Wed, 2 Jan 2019 13:14:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729450AbfABNOZ (ORCPT ); Wed, 2 Jan 2019 08:14:25 -0500 Received: from mx1.redhat.com ([209.132.183.28]:50426 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726939AbfABNOZ (ORCPT ); Wed, 2 Jan 2019 08:14:25 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id E91647F410; Wed, 2 Jan 2019 13:14:24 +0000 (UTC) Received: from localhost (ovpn-12-97.pek2.redhat.com [10.72.12.97]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 4ABE460C67; Wed, 2 Jan 2019 13:14:24 +0000 (UTC) From: Honggang Li To: hal@dev.mellanox.co.il Cc: linux-rdma@vger.kernel.org, Honggang Li Subject: [ibsim patch 12/23] sim_cmd.c: sim_cmd_file should check the char pointer before dereferening Date: Wed, 2 Jan 2019 21:13:07 +0800 Message-Id: <20190102131318.5765-12-honli@redhat.com> In-Reply-To: <20190102131318.5765-1-honli@redhat.com> References: <20190102131318.5765-1-honli@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Wed, 02 Jan 2019 13:14:25 +0000 (UTC) Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Signed-off-by: Honggang Li --- ibsim/sim_cmd.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/ibsim/sim_cmd.c b/ibsim/sim_cmd.c index 1d36c600814f..0a94c68bdf21 100644 --- a/ibsim/sim_cmd.c +++ b/ibsim/sim_cmd.c @@ -1149,11 +1149,16 @@ int sim_cmd_file(FILE * f, char *s) FILE *cmd_file; char *p; + if (!s) { + fprintf(f, "do_cmd_from_file: no file name - skip\n"); + return -1; + } + s++; while (isspace(*s)) s++; - if (!s || !*s) { + if (!*s) { fprintf(f, "do_cmd_from_file: no file name - skip\n"); return -1; } From patchwork Wed Jan 2 13:13:08 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Honggang LI X-Patchwork-Id: 10746347 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 65F2A91E for ; Wed, 2 Jan 2019 13:14:29 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5631428813 for ; Wed, 2 Jan 2019 13:14:29 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4AD7E2884B; Wed, 2 Jan 2019 13:14:29 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 070A028813 for ; Wed, 2 Jan 2019 13:14:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729907AbfABNO2 (ORCPT ); Wed, 2 Jan 2019 08:14:28 -0500 Received: from mx1.redhat.com ([209.132.183.28]:53612 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726939AbfABNO2 (ORCPT ); Wed, 2 Jan 2019 08:14:28 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 98B583C2CCC; Wed, 2 Jan 2019 13:14:28 +0000 (UTC) Received: from localhost (ovpn-12-97.pek2.redhat.com [10.72.12.97]) by smtp.corp.redhat.com (Postfix) with ESMTPS id EC17B5C71A; Wed, 2 Jan 2019 13:14:27 +0000 (UTC) From: Honggang Li To: hal@dev.mellanox.co.il Cc: linux-rdma@vger.kernel.org, Honggang Li Subject: [ibsim patch 13/23] sim_mad.c: fix potential dereference of a null pointer in do_sl2vl Date: Wed, 2 Jan 2019 21:13:08 +0800 Message-Id: <20190102131318.5765-13-honli@redhat.com> In-Reply-To: <20190102131318.5765-1-honli@redhat.com> References: <20190102131318.5765-1-honli@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Wed, 02 Jan 2019 13:14:28 +0000 (UTC) Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Issue was detected by Coverity. ibsim-0.7/ibsim/sim_mad.c:407:31: warning: Access to field 'node' results in a dereference of a null pointer (loaded from variable 'port') // if (!port && !node_get_port(port->node, n)) Signed-off-by: Honggang Li --- ibsim/sim_mad.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ibsim/sim_mad.c b/ibsim/sim_mad.c index 1660b84dbe4b..a89e2d62afd8 100644 --- a/ibsim/sim_mad.c +++ b/ibsim/sim_mad.c @@ -404,7 +404,7 @@ static int do_sl2vl(Port * port, unsigned op, uint32_t mod, uint8_t * data) n = (mod >> 8) & 0xff; port = node_get_port(port->node, n); n = mod & 0xff; - if (!port && !node_get_port(port->node, n)) + if (!port || !node_get_port(port->node, n)) return ERR_BAD_PARAM; } else n = 0; From patchwork Wed Jan 2 13:13:09 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Honggang LI X-Patchwork-Id: 10746349 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 4B970746 for ; Wed, 2 Jan 2019 13:14:33 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3B14428848 for ; Wed, 2 Jan 2019 13:14:33 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2FA9928857; Wed, 2 Jan 2019 13:14:33 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E2C5228848 for ; Wed, 2 Jan 2019 13:14:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729911AbfABNOc (ORCPT ); Wed, 2 Jan 2019 08:14:32 -0500 Received: from mx1.redhat.com ([209.132.183.28]:42974 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729909AbfABNOc (ORCPT ); Wed, 2 Jan 2019 08:14:32 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 733732D2BD3; Wed, 2 Jan 2019 13:14:32 +0000 (UTC) Received: from localhost (ovpn-12-97.pek2.redhat.com [10.72.12.97]) by smtp.corp.redhat.com (Postfix) with ESMTPS id B034660C66; Wed, 2 Jan 2019 13:14:31 +0000 (UTC) From: Honggang Li To: hal@dev.mellanox.co.il Cc: linux-rdma@vger.kernel.org, Honggang Li Subject: [ibsim patch 14/23] sim_mad.c: Fix NO_EFFECT issue for do_linearforwtbl Date: Wed, 2 Jan 2019 21:13:09 +0800 Message-Id: <20190102131318.5765-14-honli@redhat.com> In-Reply-To: <20190102131318.5765-1-honli@redhat.com> References: <20190102131318.5765-1-honli@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Wed, 02 Jan 2019 13:14:32 +0000 (UTC) Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Issue was detected by Coverity. This less-than-zero comparison of an unsigned value is never true. "mod < 0U". Signed-off-by: Honggang Li --- ibsim/sim_mad.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ibsim/sim_mad.c b/ibsim/sim_mad.c index a89e2d62afd8..b6e24881fb9e 100644 --- a/ibsim/sim_mad.c +++ b/ibsim/sim_mad.c @@ -711,7 +711,7 @@ static int do_linearforwtbl(Port * port, unsigned op, uint32_t mod, if (!sw) // not a Switch? return ERR_ATTR_UNSUPPORTED; - if (mod < 0 || mod > 767) + if (mod > 767) return ERR_BAD_PARAM; if (op == IB_MAD_METHOD_SET) From patchwork Wed Jan 2 13:13:10 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Honggang LI X-Patchwork-Id: 10746351 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 680F2746 for ; Wed, 2 Jan 2019 13:14:37 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5860A28848 for ; Wed, 2 Jan 2019 13:14:37 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4CFAA28857; Wed, 2 Jan 2019 13:14:37 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 091C028848 for ; Wed, 2 Jan 2019 13:14:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729914AbfABNOg (ORCPT ); Wed, 2 Jan 2019 08:14:36 -0500 Received: from mx1.redhat.com ([209.132.183.28]:40718 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729909AbfABNOg (ORCPT ); Wed, 2 Jan 2019 08:14:36 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 8CDEA356D3; Wed, 2 Jan 2019 13:14:36 +0000 (UTC) Received: from localhost (ovpn-12-97.pek2.redhat.com [10.72.12.97]) by smtp.corp.redhat.com (Postfix) with ESMTPS id DABC95D9CA; Wed, 2 Jan 2019 13:14:35 +0000 (UTC) From: Honggang Li To: hal@dev.mellanox.co.il Cc: linux-rdma@vger.kernel.org, Honggang Li Subject: [ibsim patch 15/23] sim_mad.c: Fix a CONSTANT_EXPRESSION_RESULT for switch_lookup Date: Wed, 2 Jan 2019 21:13:10 +0800 Message-Id: <20190102131318.5765-15-honli@redhat.com> In-Reply-To: <20190102131318.5765-1-honli@redhat.com> References: <20190102131318.5765-1-honli@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Wed, 02 Jan 2019 13:14:36 +0000 (UTC) Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Issue was detected by Coverity. "(outport = node->sw->fdb[lid]) < 0" is always false regardless of the values of its operands, because node->sw->fdb[lid] is uint8_t. Signed-off-by: Honggang Li --- ibsim/sim_mad.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/ibsim/sim_mad.c b/ibsim/sim_mad.c index b6e24881fb9e..5ef1d0a6dbeb 100644 --- a/ibsim/sim_mad.c +++ b/ibsim/sim_mad.c @@ -1579,12 +1579,11 @@ static int switch_lookup(Node * node, int lid) if (!node->sw) return -1; - if (lid > node->sw->linearFDBtop || (outport = node->sw->fdb[lid]) < 0) { + if (lid > node->sw->linearFDBtop) { IBWARN("sw guid %" PRIx64 ": bad lid %u", node->nodeguid, lid); return -1; } - - return outport; + return outport = node->sw->fdb[lid]; } static int port_get_remote(Port * port, Node ** remotenode, Port ** remoteport) From patchwork Wed Jan 2 13:13:11 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Honggang LI X-Patchwork-Id: 10746353 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id F0E6391E for ; Wed, 2 Jan 2019 13:14:40 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E159628848 for ; Wed, 2 Jan 2019 13:14:40 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D5B2528857; Wed, 2 Jan 2019 13:14:40 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8B14028848 for ; Wed, 2 Jan 2019 13:14:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729909AbfABNOk (ORCPT ); Wed, 2 Jan 2019 08:14:40 -0500 Received: from mx1.redhat.com ([209.132.183.28]:40786 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729901AbfABNOk (ORCPT ); Wed, 2 Jan 2019 08:14:40 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 414A32D7E8; Wed, 2 Jan 2019 13:14:40 +0000 (UTC) Received: from localhost (ovpn-12-97.pek2.redhat.com [10.72.12.97]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 9171B5C207; Wed, 2 Jan 2019 13:14:39 +0000 (UTC) From: Honggang Li To: hal@dev.mellanox.co.il Cc: linux-rdma@vger.kernel.org, Honggang Li Subject: [ibsim patch 16/23] umad2sim.c: make_path should check the return value of mkdir Date: Wed, 2 Jan 2019 21:13:11 +0800 Message-Id: <20190102131318.5765-16-honli@redhat.com> In-Reply-To: <20190102131318.5765-1-honli@redhat.com> References: <20190102131318.5765-1-honli@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Wed, 02 Jan 2019 13:14:40 +0000 (UTC) Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Issue was detected by Coverity. --------------------------- ibsim-0.7/umad2sim/umad2sim.c:151: check_return: Calling "mkdir(dir, 493U)" without checking return value. This library function may fail and return an error code. --------------------------- Also covert the function into a void function, as none of callers checked the return value of make_path. Signed-off-by: Honggang Li --- umad2sim/umad2sim.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/umad2sim/umad2sim.c b/umad2sim/umad2sim.c index 84ab84fd81b6..80e7b8166638 100644 --- a/umad2sim/umad2sim.c +++ b/umad2sim/umad2sim.c @@ -137,7 +137,7 @@ static void convert_sysfs_path(char *new_path, unsigned size, snprintf(new_path, size, "%s/%s", umad2sim_sysfs_prefix, old_path); } -static int make_path(char *path) +static void make_path(char *path) { char dir[1024]; char *p; @@ -148,14 +148,13 @@ static int make_path(char *path) p = strchr(p, '/'); if (p) *p = '\0'; - mkdir(dir, 0755); + if (mkdir(dir, 0755) && errno != EEXIST) + IBWARN("Failed to make directory <%s>", dir); if (p) { *p = '/'; p++; } } while (p && p[0]); - - return 0; } static int file_printf(char *path, char *name, const char *fmt, ...) From patchwork Wed Jan 2 13:13:12 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Honggang LI X-Patchwork-Id: 10746355 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id CB06591E for ; Wed, 2 Jan 2019 13:14:44 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B9CB628848 for ; Wed, 2 Jan 2019 13:14:44 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id AE24B28857; Wed, 2 Jan 2019 13:14:44 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 54F9328848 for ; Wed, 2 Jan 2019 13:14:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729916AbfABNOo (ORCPT ); Wed, 2 Jan 2019 08:14:44 -0500 Received: from mx1.redhat.com ([209.132.183.28]:43104 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729901AbfABNOo (ORCPT ); Wed, 2 Jan 2019 08:14:44 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id E6AC12D2BD3; Wed, 2 Jan 2019 13:14:43 +0000 (UTC) Received: from localhost (ovpn-12-97.pek2.redhat.com [10.72.12.97]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 41B2660C66; Wed, 2 Jan 2019 13:14:42 +0000 (UTC) From: Honggang Li To: hal@dev.mellanox.co.il Cc: linux-rdma@vger.kernel.org, Honggang Li Subject: [ibsim patch 17/23] umad2sim.c: Fix a few potential buffer overflow issues Date: Wed, 2 Jan 2019 21:13:12 +0800 Message-Id: <20190102131318.5765-17-honli@redhat.com> In-Reply-To: <20190102131318.5765-1-honli@redhat.com> References: <20190102131318.5765-1-honli@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Wed, 02 Jan 2019 13:14:43 +0000 (UTC) Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Issue was detected by Coveiry. ---- Error: CLANG_WARNING: [#def21] ibsim-0.7/umad2sim/umad2sim.c:374:26: warning: Potential buffer overflow. Replace with 'sizeof(path) - strlen(path) - 1' or use a safer 'strlcat' API // strncat(path, "/pkeys", sizeof(path) - 1); // ^~~~~~~~~~~~~~~~ ibsim-0.7/umad2sim/umad2sim.c:374:26: note: Potential buffer overflow. Replace with 'sizeof(path) - strlen(path) - 1' or use a safer 'strlcat' API // strncat(path, "/pkeys", sizeof(path) - 1); // ^~~~~~~~~~~~~~~~ // 372| /* /sys/class/infiniband/mthca0/ports/1/pkeys/0 */ // 373| str = path + strlen(path); // 374|-> strncat(path, "/pkeys", sizeof(path) - 1); // 375| make_path(path); // 376| for (i = 0; i < sizeof(sc->pkeys)/sizeof(sc->pkeys[0]); i++) { ---- Signed-off-by: Honggang Li --- umad2sim/umad2sim.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/umad2sim/umad2sim.c b/umad2sim/umad2sim.c index 80e7b8166638..c1bd8dc9d8b0 100644 --- a/umad2sim/umad2sim.c +++ b/umad2sim/umad2sim.c @@ -165,8 +165,8 @@ static int file_printf(char *path, char *name, const char *fmt, ...) int ret; convert_sysfs_path(file_name, sizeof(file_name), path); - strncat(file_name, "/", sizeof(file_name) - 1); - strncat(file_name, name, sizeof(file_name) - 1); + strncat(file_name, "/", sizeof(file_name) - strlen(file_name) - 1); + strncat(file_name, name, sizeof(file_name) - strlen(file_name) - 1); unlink(file_name); f = fopen(file_name, "w"); if (!f) { @@ -239,7 +239,7 @@ static int dev_sysfs_create(struct umad2sim_dev *dev) (uint16_t) ((guid >> 0) & 0xffff)); /* /sys/class/infiniband/mthca0/ports/ */ - strncat(path, "/ports", sizeof(path) - 1); + strncat(path, "/ports", sizeof(path) - strlen(path) - 1); make_path(path); portinfo = sc->portinfo; @@ -351,7 +351,7 @@ static int dev_sysfs_create(struct umad2sim_dev *dev) /* /sys/class/infiniband/mthca0/ports/1/gids/0 */ str = path + strlen(path); - strncat(path, "/gids", sizeof(path) - 1); + strncat(path, "/gids", sizeof(path) - strlen(path) - 1); make_path(path); *str = '\0'; gid = mad_get_field64(portinfo, 0, IB_PORT_GID_PREFIX_F); @@ -370,7 +370,7 @@ static int dev_sysfs_create(struct umad2sim_dev *dev) /* /sys/class/infiniband/mthca0/ports/1/pkeys/0 */ str = path + strlen(path); - strncat(path, "/pkeys", sizeof(path) - 1); + strncat(path, "/pkeys", sizeof(path) - strlen(path) - 1); make_path(path); for (i = 0; i < sizeof(sc->pkeys)/sizeof(sc->pkeys[0]); i++) { char name[8]; From patchwork Wed Jan 2 13:13:13 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Honggang LI X-Patchwork-Id: 10746357 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A6BF3746 for ; Wed, 2 Jan 2019 13:14:49 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 962BE28848 for ; Wed, 2 Jan 2019 13:14:49 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8AE6D28857; Wed, 2 Jan 2019 13:14:49 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D199228848 for ; Wed, 2 Jan 2019 13:14:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729918AbfABNOs (ORCPT ); Wed, 2 Jan 2019 08:14:48 -0500 Received: from mx1.redhat.com ([209.132.183.28]:55880 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729901AbfABNOs (ORCPT ); Wed, 2 Jan 2019 08:14:48 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id D9460C0828C7; Wed, 2 Jan 2019 13:14:47 +0000 (UTC) Received: from localhost (ovpn-12-97.pek2.redhat.com [10.72.12.97]) by smtp.corp.redhat.com (Postfix) with ESMTPS id E3F6760C67; Wed, 2 Jan 2019 13:14:46 +0000 (UTC) From: Honggang Li To: hal@dev.mellanox.co.il Cc: linux-rdma@vger.kernel.org, Honggang Li Subject: [ibsim patch 18/23] sim_net.c: initialize the pointer sp with NULL for parse_port Date: Wed, 2 Jan 2019 21:13:13 +0800 Message-Id: <20190102131318.5765-18-honli@redhat.com> In-Reply-To: <20190102131318.5765-1-honli@redhat.com> References: <20190102131318.5765-1-honli@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Wed, 02 Jan 2019 13:14:47 +0000 (UTC) Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP These two issues were detected by Coverity. Error: CLANG_WARNING: [#def6] ibsim-0.7/ibsim/sim_net.c:786:2: warning: 7th function call argument is an uninitialized value // PDEBUG("remotenodeid %s s %s sp %s", remotenodeid, s, sp); // ^ ibsim-0.7/ibsim/sim_net.c:56:32: note: expanded from macro 'PDEBUG' //#define PDEBUG if (parsedebug) IBWARN // ^ /usr/include/infiniband/mad.h:1716:26: note: expanded from macro 'IBWARN' //#define IBWARN(fmt, ...) fprintf(stderr, "ibwarn: [%d] %s: " fmt "\n", \ // ^ ibsim-0.7/ibsim/sim_net.c:741:33: note: 'sp' declared without an initial value // char remotenodeid[NODEIDLEN], *sp; // ^~ ibsim-0.7/ibsim/sim_net.c:746:6: note: Assuming the condition is false // if (line[0] == '@') { // ^~~~~~~~~~~~~~ ibsim-0.7/ibsim/sim_net.c:746:2: note: Taking false branch // if (line[0] == '@') { // ^ ibsim-0.7/ibsim/sim_net.c:753:6: note: Assuming 'portnum' is >= 0 // if (portnum < 0 || portnum > maxports) { // ^~~~~~~~~~~ ibsim-0.7/ibsim/sim_net.c:753:6: note: Left side of '||' is false ibsim-0.7/ibsim/sim_net.c:753:21: note: Assuming 'portnum' is <= 'maxports' // if (portnum < 0 || portnum > maxports) { // ^~~~~~~~~~~~~~~~~~ ibsim-0.7/ibsim/sim_net.c:753:2: note: Taking false branch // if (portnum < 0 || portnum > maxports) { // ^ ibsim-0.7/ibsim/sim_net.c:757:6: note: Assuming 'portnum' is not equal to 0 // if (!portnum && line[1] != 0) { // ^~~~~~~~ ibsim-0.7/ibsim/sim_net.c:757:15: note: Left side of '&&' is false // if (!portnum && line[1] != 0) { // ^ ibsim-0.7/ibsim/sim_net.c:764:6: note: Assuming 'type' is equal to SWITCH_NODE // if (type != SWITCH_NODE && !portnum) { // ^~~~~~~~~~~~~~~~~~~ ibsim-0.7/ibsim/sim_net.c:764:26: note: Left side of '&&' is false // if (type != SWITCH_NODE && !portnum) { // ^ ibsim-0.7/ibsim/sim_net.c:769:2: note: Taking false branch // if (!(s = parse_node_id(line, NULL))) { // ^ ibsim-0.7/ibsim/sim_net.c:774:2: note: Taking false branch // if (isalias) { // ^ ibsim-0.7/ibsim/sim_net.c:782:6: note: Assuming the condition is false // if (strchr(s, '@')) // ^~~~~~~~~~~~~~ ibsim-0.7/ibsim/sim_net.c:782:2: note: Taking false branch // if (strchr(s, '@')) // ^ ibsim-0.7/ibsim/sim_net.c:785:2: note: Calling 'expand_name' // expand_name(s, remotenodeid, &sp); // ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ibsim-0.7/ibsim/sim_net.c:683:2: note: Taking false branch // if (!base) // ^ ibsim-0.7/ibsim/sim_net.c:686:6: note: Assuming the condition is false // if (!strchr(base, '@')) { // ^~~~~~~~~~~~~~~~~~ ibsim-0.7/ibsim/sim_net.c:686:2: note: Taking false branch // if (!strchr(base, '@')) { // ^ ibsim-0.7/ibsim/sim_net.c:697:36: note: Assuming the condition is false // snprintf(name, NODEIDLEN, "%s%s", base[0] == '@' ? netprefix : "", base); // ^~~~~~~~~~~~~~ ibsim-0.7/ibsim/sim_net.c:697:36: note: '?' condition is false ibsim-0.7/ibsim/sim_net.c:698:2: note: Assuming 'parsedebug' is 0 // PDEBUG("alias %s", name); // ^~~~~~ ibsim-0.7/ibsim/sim_net.c:56:20: note: expanded from macro 'PDEBUG' //#define PDEBUG if (parsedebug) IBWARN // ^~~~~~~~~~ ibsim-0.7/ibsim/sim_net.c:698:2: note: Taking false branch ibsim-0.7/ibsim/sim_net.c:56:16: note: expanded from macro 'PDEBUG' //#define PDEBUG if (parsedebug) IBWARN // ^ ibsim-0.7/ibsim/sim_net.c:700:8: note: Assuming 's' is null // if (!(s = map_alias(name))) // ^ ibsim-0.7/ibsim/sim_net.c:700:2: note: Taking true branch // if (!(s = map_alias(name))) // ^ ibsim-0.7/ibsim/sim_net.c:701:3: note: Returning without writing to '*portstr' // return NULL; // ^ ibsim-0.7/ibsim/sim_net.c:785:2: note: Returning from 'expand_name' // expand_name(s, remotenodeid, &sp); // ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ibsim-0.7/ibsim/sim_net.c:786:2: note: Assuming 'parsedebug' is not equal to 0 // PDEBUG("remotenodeid %s s %s sp %s", remotenodeid, s, sp); // ^~~~~~ ibsim-0.7/ibsim/sim_net.c:56:20: note: expanded from macro 'PDEBUG' //#define PDEBUG if (parsedebug) IBWARN // ^~~~~~~~~~ ibsim-0.7/ibsim/sim_net.c:786:2: note: Taking true branch ibsim-0.7/ibsim/sim_net.c:56:16: note: expanded from macro 'PDEBUG' //#define PDEBUG if (parsedebug) IBWARN // ^ ibsim-0.7/ibsim/sim_net.c:786:2: note: 7th function call argument is an uninitialized value // PDEBUG("remotenodeid %s s %s sp %s", remotenodeid, s, sp); // ^ ~~ ibsim-0.7/ibsim/sim_net.c:56:32: note: expanded from macro 'PDEBUG' //#define PDEBUG if (parsedebug) IBWARN // ^ /usr/include/infiniband/mad.h:1716:26: note: expanded from macro 'IBWARN' //#define IBWARN(fmt, ...) fprintf(stderr, "ibwarn: [%d] %s: " fmt "\n", \ // ^ // 784| // 785| expand_name(s, remotenodeid, &sp); // 786|-> PDEBUG("remotenodeid %s s %s sp %s", remotenodeid, s, sp); // 787| // 788| s += strlen(s) + 1; Error: CLANG_WARNING: [#def7] ibsim-0.7/ibsim/sim_net.c:789:6: warning: Branch condition evaluates to a garbage value // if (!sp && *s == '[') // ^~~ ibsim-0.7/ibsim/sim_net.c:741:33: note: 'sp' declared without an initial value // char remotenodeid[NODEIDLEN], *sp; // ^~ ibsim-0.7/ibsim/sim_net.c:746:6: note: Assuming the condition is false // if (line[0] == '@') { // ^~~~~~~~~~~~~~ ibsim-0.7/ibsim/sim_net.c:746:2: note: Taking false branch // if (line[0] == '@') { // ^ ibsim-0.7/ibsim/sim_net.c:753:6: note: Assuming 'portnum' is >= 0 // if (portnum < 0 || portnum > maxports) { // ^~~~~~~~~~~ ibsim-0.7/ibsim/sim_net.c:753:6: note: Left side of '||' is false ibsim-0.7/ibsim/sim_net.c:753:21: note: Assuming 'portnum' is <= 'maxports' // if (portnum < 0 || portnum > maxports) { // ^~~~~~~~~~~~~~~~~~ ibsim-0.7/ibsim/sim_net.c:753:2: note: Taking false branch // if (portnum < 0 || portnum > maxports) { // ^ ibsim-0.7/ibsim/sim_net.c:757:6: note: Assuming 'portnum' is not equal to 0 // if (!portnum && line[1] != 0) { // ^~~~~~~~ ibsim-0.7/ibsim/sim_net.c:757:15: note: Left side of '&&' is false // if (!portnum && line[1] != 0) { // ^ ibsim-0.7/ibsim/sim_net.c:764:6: note: Assuming 'type' is equal to SWITCH_NODE // if (type != SWITCH_NODE && !portnum) { // ^~~~~~~~~~~~~~~~~~~ ibsim-0.7/ibsim/sim_net.c:764:26: note: Left side of '&&' is false // if (type != SWITCH_NODE && !portnum) { // ^ ibsim-0.7/ibsim/sim_net.c:769:2: note: Taking false branch // if (!(s = parse_node_id(line, NULL))) { // ^ ibsim-0.7/ibsim/sim_net.c:774:2: note: Taking false branch // if (isalias) { // ^ ibsim-0.7/ibsim/sim_net.c:782:6: note: Assuming the condition is false // if (strchr(s, '@')) // ^~~~~~~~~~~~~~ ibsim-0.7/ibsim/sim_net.c:782:2: note: Taking false branch // if (strchr(s, '@')) // ^ ibsim-0.7/ibsim/sim_net.c:785:2: note: Calling 'expand_name' // expand_name(s, remotenodeid, &sp); // ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ibsim-0.7/ibsim/sim_net.c:683:2: note: Taking false branch // if (!base) // ^ ibsim-0.7/ibsim/sim_net.c:686:6: note: Assuming the condition is false // if (!strchr(base, '@')) { // ^~~~~~~~~~~~~~~~~~ ibsim-0.7/ibsim/sim_net.c:686:2: note: Taking false branch // if (!strchr(base, '@')) { // ^ ibsim-0.7/ibsim/sim_net.c:697:36: note: Assuming the condition is false // snprintf(name, NODEIDLEN, "%s%s", base[0] == '@' ? netprefix : "", base); // ^~~~~~~~~~~~~~ ibsim-0.7/ibsim/sim_net.c:697:36: note: '?' condition is false ibsim-0.7/ibsim/sim_net.c:698:2: note: Assuming 'parsedebug' is 0 // PDEBUG("alias %s", name); // ^~~~~~ ibsim-0.7/ibsim/sim_net.c:56:20: note: expanded from macro 'PDEBUG' //#define PDEBUG if (parsedebug) IBWARN // ^~~~~~~~~~ ibsim-0.7/ibsim/sim_net.c:698:2: note: Taking false branch ibsim-0.7/ibsim/sim_net.c:56:16: note: expanded from macro 'PDEBUG' //#define PDEBUG if (parsedebug) IBWARN // ^ ibsim-0.7/ibsim/sim_net.c:700:8: note: Assuming 's' is null // if (!(s = map_alias(name))) // ^ ibsim-0.7/ibsim/sim_net.c:700:2: note: Taking true branch // if (!(s = map_alias(name))) // ^ ibsim-0.7/ibsim/sim_net.c:701:3: note: Returning without writing to '*portstr' // return NULL; // ^ ibsim-0.7/ibsim/sim_net.c:785:2: note: Returning from 'expand_name' // expand_name(s, remotenodeid, &sp); // ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ibsim-0.7/ibsim/sim_net.c:789:6: note: Branch condition evaluates to a garbage value // if (!sp && *s == '[') // ^~~ // 787| // 788| s += strlen(s) + 1; // 789|-> if (!sp && *s == '[') // 790| sp = s + 1; // 791| Signed-off-by: Honggang Li --- ibsim/sim_net.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ibsim/sim_net.c b/ibsim/sim_net.c index 8f285e6d8f1a..bdce93a6ac10 100644 --- a/ibsim/sim_net.c +++ b/ibsim/sim_net.c @@ -738,7 +738,7 @@ static int new_alias(char *alias, Node * node, int portnum) static int parse_port(char *line, Node * node, int type, int maxports) { - char remotenodeid[NODEIDLEN], *sp; + char remotenodeid[NODEIDLEN], *sp = NULL; int portnum, isalias = 0; Port *port; char *s; From patchwork Wed Jan 2 13:13:14 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Honggang LI X-Patchwork-Id: 10746359 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 8D02791E for ; Wed, 2 Jan 2019 13:14:52 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7E3B328848 for ; Wed, 2 Jan 2019 13:14:52 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 72C0828857; Wed, 2 Jan 2019 13:14:52 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2AC0128848 for ; Wed, 2 Jan 2019 13:14:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729921AbfABNOw (ORCPT ); Wed, 2 Jan 2019 08:14:52 -0500 Received: from mx1.redhat.com ([209.132.183.28]:43211 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729901AbfABNOv (ORCPT ); Wed, 2 Jan 2019 08:14:51 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id C41CE33BE4; Wed, 2 Jan 2019 13:14:51 +0000 (UTC) Received: from localhost (ovpn-12-97.pek2.redhat.com [10.72.12.97]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 209201001947; Wed, 2 Jan 2019 13:14:50 +0000 (UTC) From: Honggang Li To: hal@dev.mellanox.co.il Cc: linux-rdma@vger.kernel.org, Honggang Li Subject: [ibsim patch 19/23] sim_cmd.c: Delete unused value Date: Wed, 2 Jan 2019 21:13:14 +0800 Message-Id: <20190102131318.5765-19-honli@redhat.com> In-Reply-To: <20190102131318.5765-1-honli@redhat.com> References: <20190102131318.5765-1-honli@redhat.com> X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Wed, 02 Jan 2019 13:14:51 +0000 (UTC) Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Issue was detected by Coverity. Error: CLANG_WARNING: [#def3] ibsim-0.7/ibsim/sim_cmd.c:540:3: warning: Value stored to 'n' is never read // n += sprintf(comment+n, "\t# err_attr %d", port->errattr); // ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ibsim-0.7/ibsim/sim_cmd.c:540:3: note: Value stored to 'n' is never read // n += sprintf(comment+n, "\t# err_attr %d", port->errattr); // ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // 538| n += sprintf(comment, "\t# err_rate %d", port->errrate); // 539| if (port->errattr) // 540|-> n += sprintf(comment+n, "\t# err_attr %d", port->errattr); // 541| } // 542| Signed-off-by: Honggang Li --- ibsim/sim_cmd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ibsim/sim_cmd.c b/ibsim/sim_cmd.c index 0a94c68bdf21..325292103caa 100644 --- a/ibsim/sim_cmd.c +++ b/ibsim/sim_cmd.c @@ -537,7 +537,7 @@ static void dump_comment(Port * port, char *comment) if (port->errrate) n += sprintf(comment, "\t# err_rate %d", port->errrate); if (port->errattr) - n += sprintf(comment+n, "\t# err_attr %d", port->errattr); + sprintf(comment+n, "\t# err_attr %d", port->errattr); } static void dump_port(FILE * f, Port * port, int type) From patchwork Wed Jan 2 13:13:15 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Honggang LI X-Patchwork-Id: 10746361 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id D392B91E for ; Wed, 2 Jan 2019 13:14:56 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C3D1928857 for ; Wed, 2 Jan 2019 13:14:56 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B53A72884B; Wed, 2 Jan 2019 13:14:56 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4768E2884B for ; Wed, 2 Jan 2019 13:14:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729923AbfABNO4 (ORCPT ); Wed, 2 Jan 2019 08:14:56 -0500 Received: from mx1.redhat.com ([209.132.183.28]:60210 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729901AbfABNO4 (ORCPT ); Wed, 2 Jan 2019 08:14:56 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id B3952C0669D2; Wed, 2 Jan 2019 13:14:55 +0000 (UTC) Received: from localhost (ovpn-12-97.pek2.redhat.com [10.72.12.97]) by smtp.corp.redhat.com (Postfix) with ESMTPS id E37221001F4A; Wed, 2 Jan 2019 13:14:54 +0000 (UTC) From: Honggang Li To: hal@dev.mellanox.co.il Cc: linux-rdma@vger.kernel.org, Honggang Li Subject: [ibsim patch 20/23] ibsim.spec.in: Improve the spec file as Fedora package guide requires Date: Wed, 2 Jan 2019 21:13:15 +0800 Message-Id: <20190102131318.5765-20-honli@redhat.com> In-Reply-To: <20190102131318.5765-1-honli@redhat.com> References: <20190102131318.5765-1-honli@redhat.com> X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Wed, 02 Jan 2019 13:14:55 +0000 (UTC) Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP - Delete the 'Group' tag as it is outdated. - Delete the 'BuildRoot' tag as it is unnecessary. - Update the 'Source' and 'Url' tag as ibsim now hosted in github. - The 'description' section is too long. Each line should less than 80 characters. - Delete the environment variables in 'build' section, as they use the default values. - Simplify the 'install' section. - The 'clean' section is unnecessary. - The default 'defattr' tag is unnecessary. - ibsim should own the umad2sim directory too. - Move 'COPYING' file into the license tag. Signed-off-by: Honggang Li --- ibsim.spec.in | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/ibsim.spec.in b/ibsim.spec.in index 424b2e01ed60..d1936a300d86 100644 --- a/ibsim.spec.in +++ b/ibsim.spec.in @@ -7,14 +7,13 @@ Name: ibsim Version: @VERSION@ Release: %rel%{?dist} License: GPLv2 or BSD -Group: System Environment/Libraries -BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) -Source: http://www.openfabrics.org/downloads/management/@TARBALL@ -Url: http://openfabrics.org/ +Source: https://github.com/linux-rdma/ibsim/archive/@TARBALL@ +Url: https://github.com/linux-rdma/ibsim BuildRequires: libibmad-devel, libibumad-devel, gcc %description -ibsim provides simulation of infiniband fabric for using with OFA OpenSM, diagnostic and management tools. +ibsim provides simulation of infiniband fabric for using with +OFA OpenSM, diagnostic and management tools. %prep %setup -q @@ -22,20 +21,15 @@ ibsim provides simulation of infiniband fabric for using with OFA OpenSM, diagno %build export CFLAGS="${CFLAGS:-${RPM_OPT_FLAGS}}" export LDFLAGS="${LDFLAGS:-${RPM_OPT_FLAGS}}" -make prefix=%_prefix libpath=%_libdir binpath=%_bindir %{?_smp_mflags} +make %{?_smp_mflags} %install -export CFLAGS="${CFLAGS:-${RPM_OPT_FLAGS}}" -export LDFLAGS="${LDFLAGS:-${RPM_OPT_FLAGS}}" make DESTDIR=${RPM_BUILD_ROOT} prefix=%_prefix libpath=%_libdir binpath=%_bindir install -%clean -rm -rf $RPM_BUILD_ROOT - %files -%defattr(-,root,root) -%{_libdir}/umad2sim/libumad2sim*.so* +%{_libdir}/umad2sim/ %{_bindir}/ibsim -%doc README COPYING TODO net-examples scripts +%doc README TODO net-examples scripts +%license COPYING %changelog From patchwork Wed Jan 2 13:13:16 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Honggang LI X-Patchwork-Id: 10746363 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 74BA5746 for ; Wed, 2 Jan 2019 13:15:00 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6121E2884B for ; Wed, 2 Jan 2019 13:15:00 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 531152885E; Wed, 2 Jan 2019 13:15:00 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F059A2884B for ; Wed, 2 Jan 2019 13:14:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729474AbfABNO7 (ORCPT ); Wed, 2 Jan 2019 08:14:59 -0500 Received: from mx1.redhat.com ([209.132.183.28]:60934 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729324AbfABNO7 (ORCPT ); Wed, 2 Jan 2019 08:14:59 -0500 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 5ED1A80F75; Wed, 2 Jan 2019 13:14:59 +0000 (UTC) Received: from localhost (ovpn-12-97.pek2.redhat.com [10.72.12.97]) by smtp.corp.redhat.com (Postfix) with ESMTPS id B4B32450A; Wed, 2 Jan 2019 13:14:58 +0000 (UTC) From: Honggang Li To: hal@dev.mellanox.co.il Cc: linux-rdma@vger.kernel.org, Honggang Li Subject: [ibsim patch 21/23] sim_net.c: Free pattern buffer Date: Wed, 2 Jan 2019 21:13:16 +0800 Message-Id: <20190102131318.5765-21-honli@redhat.com> In-Reply-To: <20190102131318.5765-1-honli@redhat.com> References: <20190102131318.5765-1-honli@redhat.com> X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Wed, 02 Jan 2019 13:14:59 +0000 (UTC) Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP ==11591== 9,824 (1,792 direct, 8,032 indirect) bytes in 8 blocks are definitely lost in loss record 36 of 36 ==11591== at 0x4C2ED48: malloc (vg_replace_malloc.c:298) ==11591== by 0x4C31363: realloc (vg_replace_malloc.c:826) ==11591== by 0x533D25C: re_compile_internal (in /usr/lib64/libc-2.27.so) ==11591== by 0x533DC3B: regcomp (in /usr/lib64/libc-2.27.so) ==11591== by 0x402BEB: parse_port_connection_data (sim_net.c:531) ==11591== by 0x403CBF: parse_port (sim_net.c:815) ==11591== by 0x403DF7: parse_ports (sim_net.c:842) ==11591== by 0x404021: parse_switch (sim_net.c:904) ==11591== by 0x4049CB: parse_netconf (sim_net.c:1111) ==11591== by 0x404F1F: read_netconf (sim_net.c:1166) ==11591== by 0x4126D4: sim_init_net (ibsim.c:523) ==11591== by 0x413445: main (ibsim.c:777) Signed-off-by: Honggang Li --- ibsim/sim_net.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/ibsim/sim_net.c b/ibsim/sim_net.c index bdce93a6ac10..068c38ef9f52 100644 --- a/ibsim/sim_net.c +++ b/ibsim/sim_net.c @@ -533,6 +533,7 @@ static int parse_port_connection_data(Port * port, int type, char *line) if (rc) { IBWARN("cannot parse remote lid and connection type"); + regfree(®ex); return 0; } @@ -542,18 +543,23 @@ static int parse_port_connection_data(Port * port, int type, char *line) /* expecting line with the following format: * [1] "H-000123456789ABCD"[2](123456789ABCE) # "description" lid 1 4xQDR ... */ - if (parse_port_link_width_and_speed(port, line_connection_type)) + if (parse_port_link_width_and_speed(port, line_connection_type)) { + regfree(®ex); return -1; + } } if (type == HCA_NODE) { /* expecting line with the following format: * [1](123456789ABCDE) "S-000123456789ABCDF"[2] # lid 2 lmc 0 "description" lid 1 4xQDR ... */ if (parse_port_lid_and_lmc(port, line) || - parse_port_link_width_and_speed(port, line_connection_type)) + parse_port_link_width_and_speed(port, line_connection_type)) { + regfree(®ex); return -1; + } } + regfree(®ex); return 0; } From patchwork Wed Jan 2 13:13:17 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Honggang LI X-Patchwork-Id: 10746365 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 15BE11399 for ; Wed, 2 Jan 2019 13:15:07 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 03F3628848 for ; Wed, 2 Jan 2019 13:15:07 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E89CB28857; Wed, 2 Jan 2019 13:15:06 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 79D9728848 for ; Wed, 2 Jan 2019 13:15:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729901AbfABNPG (ORCPT ); Wed, 2 Jan 2019 08:15:06 -0500 Received: from mx1.redhat.com ([209.132.183.28]:53890 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728111AbfABNPG (ORCPT ); Wed, 2 Jan 2019 08:15:06 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id B8EA052748; Wed, 2 Jan 2019 13:15:05 +0000 (UTC) Received: from localhost (ovpn-12-97.pek2.redhat.com [10.72.12.97]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 64E0D60C66; Wed, 2 Jan 2019 13:15:02 +0000 (UTC) From: Honggang Li To: hal@dev.mellanox.co.il Cc: linux-rdma@vger.kernel.org, Honggang Li Subject: [ibsim patch 22/23] sim_cmd.c: Fix out of bound memory access in do_cmd Date: Wed, 2 Jan 2019 21:13:17 +0800 Message-Id: <20190102131318.5765-22-honli@redhat.com> In-Reply-To: <20190102131318.5765-1-honli@redhat.com> References: <20190102131318.5765-1-honli@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Wed, 02 Jan 2019 13:15:05 +0000 (UTC) Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP ==6662== 287 errors in context 1 of 1: ==6662== Use of uninitialised value of size 8 ==6662== at 0x4108EA: do_cmd (sim_cmd.c:1199) ==6662== by 0x412976: sim_run_console (ibsim.c:563) ==6662== by 0x412D24: sim_run (ibsim.c:604) ==6662== by 0x41352E: main (ibsim.c:783) ==6662== Uninitialised value was created by a stack allocation ==6662== at 0x4128EF: sim_run_console (ibsim.c:552) Signed-off-by: Honggang Li --- ibsim/sim_cmd.c | 59 ++++++++++++++++++++++++++++++++------------------------- 1 file changed, 33 insertions(+), 26 deletions(-) diff --git a/ibsim/sim_cmd.c b/ibsim/sim_cmd.c index 325292103caa..fe3e3067882d 100644 --- a/ibsim/sim_cmd.c +++ b/ibsim/sim_cmd.c @@ -1188,69 +1188,76 @@ int sim_cmd_file(FILE * f, char *s) int netstarted; +static int match_command(char * line, char *cmd, unsigned int cmd_len) +{ + if (cmd_len != strlen(cmd)) + return 0; + return !(strncasecmp(line, cmd, strlen(cmd))); +} + int do_cmd(char *buf, FILE *f) { unsigned int cmd_len = 0; char *line; int r = 0; + unsigned int max_cmd_len, i; for (line = buf; *line && isspace(*line); line++) ; - while (!isspace(line[cmd_len])) - cmd_len++; + max_cmd_len = strlen(line); + for (i=0; i X-Patchwork-Id: 10746367 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 906E791E for ; Wed, 2 Jan 2019 13:15:10 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7FACA28848 for ; Wed, 2 Jan 2019 13:15:10 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7396928857; Wed, 2 Jan 2019 13:15:10 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2775028848 for ; Wed, 2 Jan 2019 13:15:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729924AbfABNPK (ORCPT ); Wed, 2 Jan 2019 08:15:10 -0500 Received: from mx1.redhat.com ([209.132.183.28]:53932 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728111AbfABNPJ (ORCPT ); Wed, 2 Jan 2019 08:15:09 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id C206B46233; Wed, 2 Jan 2019 13:15:09 +0000 (UTC) Received: from localhost (ovpn-12-97.pek2.redhat.com [10.72.12.97]) by smtp.corp.redhat.com (Postfix) with ESMTPS id BA9495D75E; Wed, 2 Jan 2019 13:15:08 +0000 (UTC) From: Honggang Li To: hal@dev.mellanox.co.il Cc: linux-rdma@vger.kernel.org, Honggang Li Subject: [ibsim patch 23/23] sim_mad.c: Fix accessing of uninitialised memory in send_trap Date: Wed, 2 Jan 2019 21:13:18 +0800 Message-Id: <20190102131318.5765-23-honli@redhat.com> In-Reply-To: <20190102131318.5765-1-honli@redhat.com> References: <20190102131318.5765-1-honli@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Wed, 02 Jan 2019 13:15:09 +0000 (UTC) Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP ==11780== 4 errors in context 1 of 1: ==11780== Syscall param write(buf) points to uninitialised byte(s) ==11780== at 0x5349F34: write (in /usr/lib64/libc-2.27.so) ==11780== by 0x40CA7E: send_trap (sim_mad.c:2014) ==11780== by 0x407D57: do_portinfo (sim_mad.c:672) ==11780== by 0x40C2CD: process_packet (sim_mad.c:1887) ==11780== by 0x41254B: sim_read_pkt (ibsim.c:484) ==11780== by 0x412D49: sim_run (ibsim.c:601) ==11780== by 0x4135B3: main (ibsim.c:783) ==11780== Address 0x1ffeffed44 is on thread 1's stack ==11780== in frame #1, created by send_trap (sim_mad.c:1971) ==11780== Uninitialised value was created by a stack allocation ==11780== at 0x40C832: send_trap (sim_mad.c:1971) Signed-off-by: Honggang Li --- ibsim/sim_mad.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ibsim/sim_mad.c b/ibsim/sim_mad.c index 5ef1d0a6dbeb..dfd1a31e178e 100644 --- a/ibsim/sim_mad.c +++ b/ibsim/sim_mad.c @@ -1982,7 +1982,7 @@ int send_trap(Port * port, unsigned trapnum) } encode_trapfn = encodetrap[trapnum]; - memset(req.mad, 0, sizeof(req.mad)); + memset(&req, 0, sizeof(req)); encode_trap_header(req.mad); if (encode_trapfn(port, data) < 0) return -1;