From patchwork Mon Aug 27 06:42:29 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Honggang LI X-Patchwork-Id: 10576405 X-Patchwork-Delegate: hal@mellanox.com 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 C574A174A for ; Mon, 27 Aug 2018 06:42:59 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AE1CE2943F for ; Mon, 27 Aug 2018 06:42:59 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A017229721; Mon, 27 Aug 2018 06:42: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 3357F2943F for ; Mon, 27 Aug 2018 06:42:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727065AbeH0K2L (ORCPT ); Mon, 27 Aug 2018 06:28:11 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:58698 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726874AbeH0K2L (ORCPT ); Mon, 27 Aug 2018 06:28:11 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 404B94023ECB; Mon, 27 Aug 2018 06:42:54 +0000 (UTC) Received: from lhg.nay.redhat.com (unknown [10.66.129.124]) by smtp.corp.redhat.com (Postfix) with ESMTP id A12DE2166B41; Mon, 27 Aug 2018 06:42:52 +0000 (UTC) From: Honggang LI To: hal@dev.mellanox.co.il Cc: linux-rdma@vger.kernel.org, Honggang Li Subject: [PATCH 1/5] Adjust BuildRequires for covscan Date: Mon, 27 Aug 2018 14:42:29 +0800 Message-Id: <20180827064233.3218-1-honli@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.7]); Mon, 27 Aug 2018 06:42:54 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.7]); Mon, 27 Aug 2018 06:42:54 +0000 (UTC) for IP:'10.11.54.6' DOMAIN:'int-mx06.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'honli@redhat.com' RCPT:'' 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 From: Honggang Li Signed-off-by: Honggang Li --- opensm.spec.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/opensm.spec.in b/opensm.spec.in index 29dc481d..a96dbb54 100644 --- a/opensm.spec.in +++ b/opensm.spec.in @@ -34,7 +34,7 @@ Group: System Environment/Daemons URL: http://openfabrics.org/ Source: http://www.openfabrics.org/downloads/management/@TARBALL@ BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) -BuildRequires: libibumad-devel, libtool +BuildRequires: libibumad-devel, libtool, gcc, bison, flex Requires: %{name}-libs = %{version}-%{release}, logrotate %description From patchwork Mon Aug 27 06:42:30 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Honggang LI X-Patchwork-Id: 10576409 X-Patchwork-Delegate: hal@mellanox.com 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 294DD15A7 for ; Mon, 27 Aug 2018 06:43:01 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1CD322943F for ; Mon, 27 Aug 2018 06:43:01 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 116842971F; Mon, 27 Aug 2018 06:43:01 +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 548402971E for ; Mon, 27 Aug 2018 06:42:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727072AbeH0K2O (ORCPT ); Mon, 27 Aug 2018 06:28:14 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:45458 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726874AbeH0K2O (ORCPT ); Mon, 27 Aug 2018 06:28:14 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 715A24023461; Mon, 27 Aug 2018 06:42:56 +0000 (UTC) Received: from lhg.nay.redhat.com (unknown [10.66.129.124]) by smtp.corp.redhat.com (Postfix) with ESMTP id D2F972166B41; Mon, 27 Aug 2018 06:42:54 +0000 (UTC) From: Honggang LI To: hal@dev.mellanox.co.il Cc: linux-rdma@vger.kernel.org, Honggang Li Subject: [PATCH 2/5] Close fd before return to avoid resource leak Date: Mon, 27 Aug 2018 14:42:30 +0800 Message-Id: <20180827064233.3218-2-honli@redhat.com> In-Reply-To: <20180827064233.3218-1-honli@redhat.com> References: <20180827064233.3218-1-honli@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.6]); Mon, 27 Aug 2018 06:42:56 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.6]); Mon, 27 Aug 2018 06:42:56 +0000 (UTC) for IP:'10.11.54.6' DOMAIN:'int-mx06.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'honli@redhat.com' RCPT:'' 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 From: Honggang Li Issue was found by Coverity. Signed-off-by: Honggang Li --- opensm/main.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/opensm/main.c b/opensm/main.c index ba20d985..2d23fe2b 100644 --- a/opensm/main.c +++ b/opensm/main.c @@ -565,6 +565,8 @@ static int daemonize(osm_opensm_t * osm) dup2(fd, 1); dup2(fd, 2); + close(fd); + return 0; } From patchwork Mon Aug 27 06:42:31 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Honggang LI X-Patchwork-Id: 10576407 X-Patchwork-Delegate: hal@mellanox.com 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 EF813174A for ; Mon, 27 Aug 2018 06:43:00 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E21B82943F for ; Mon, 27 Aug 2018 06:43:00 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D638829721; Mon, 27 Aug 2018 06:43: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 7D0DE2943F for ; Mon, 27 Aug 2018 06:43:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727081AbeH0K2Q (ORCPT ); Mon, 27 Aug 2018 06:28:16 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:35390 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726874AbeH0K2P (ORCPT ); Mon, 27 Aug 2018 06:28:15 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id A251F8573A; Mon, 27 Aug 2018 06:42:58 +0000 (UTC) Received: from lhg.nay.redhat.com (unknown [10.66.129.124]) by smtp.corp.redhat.com (Postfix) with ESMTP id 10E612166B41; Mon, 27 Aug 2018 06:42:56 +0000 (UTC) From: Honggang LI To: hal@dev.mellanox.co.il Cc: linux-rdma@vger.kernel.org, Honggang Li Subject: [PATCH 3/5] osm_port.c: osm_port_new fix memory leak Date: Mon, 27 Aug 2018 14:42:31 +0800 Message-Id: <20180827064233.3218-3-honli@redhat.com> In-Reply-To: <20180827064233.3218-2-honli@redhat.com> References: <20180827064233.3218-1-honli@redhat.com> <20180827064233.3218-2-honli@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.2]); Mon, 27 Aug 2018 06:42:58 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.2]); Mon, 27 Aug 2018 06:42:58 +0000 (UTC) for IP:'10.11.54.6' DOMAIN:'int-mx06.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'honli@redhat.com' RCPT:'' 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 From: Honggang Li Issue was found by Coverity. Error: RESOURCE_LEAK (CWE-772): [#def9] opensm-3.3.20/opensm/osm_port.c:146: alloc_fn: Storage is returned from allocation function "malloc". opensm-3.3.20/opensm/osm_port.c:146: var_assign: Assigning: "p_port" = storage returned from "malloc(168UL)". opensm-3.3.20/opensm/osm_port.c:150: noescape: Resource "p_port" is not freed or pointed-to in "memset". [Note: The source code implementation of the function has been overridden by a builtin model.] opensm-3.3.20/opensm/osm_port.c:151: noescape: Resource "&p_port->mcm_list" is not freed or pointed-to in "cl_qlist_init". opensm-3.3.20/include/complib/cl_qlist.h:435:56: noescape: "cl_qlist_init(cl_qlist_t * const)" does not free or save its parameter "p_list". opensm-3.3.20/opensm/osm_port.c:166: leaked_storage: Variable "p_port" going out of scope leaks the storage it points to. |# 164| p_physp = osm_node_get_physp_ptr(p_parent_node, port_num); |# 165| if (!p_physp) |# 166|-> return NULL; |# 167| |# 168| CL_ASSERT(port_guid == osm_physp_get_port_guid(p_physp)); Signed-off-by: Honggang Li --- opensm/osm_port.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/opensm/osm_port.c b/opensm/osm_port.c index c732f990..1246edf9 100644 --- a/opensm/osm_port.c +++ b/opensm/osm_port.c @@ -162,8 +162,10 @@ osm_port_t *osm_port_new(IN const ib_node_info_t * p_ni, only the singular part that has this GUID is owned. */ p_physp = osm_node_get_physp_ptr(p_parent_node, port_num); - if (!p_physp) + if (!p_physp) { + free(p_port); return NULL; + } CL_ASSERT(port_guid == osm_physp_get_port_guid(p_physp)); p_port->p_physp = p_physp; From patchwork Mon Aug 27 06:42:32 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Honggang LI X-Patchwork-Id: 10576411 X-Patchwork-Delegate: hal@mellanox.com 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 DE9EC15A7 for ; Mon, 27 Aug 2018 06:43:02 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D275B29720 for ; Mon, 27 Aug 2018 06:43:02 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C472E2971F; Mon, 27 Aug 2018 06:43:02 +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 74AD22971F for ; Mon, 27 Aug 2018 06:43:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727085AbeH0K2S (ORCPT ); Mon, 27 Aug 2018 06:28:18 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:46752 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726874AbeH0K2S (ORCPT ); Mon, 27 Aug 2018 06:28:18 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id D628683221; Mon, 27 Aug 2018 06:43:00 +0000 (UTC) Received: from lhg.nay.redhat.com (unknown [10.66.129.124]) by smtp.corp.redhat.com (Postfix) with ESMTP id 431682166B41; Mon, 27 Aug 2018 06:42:58 +0000 (UTC) From: Honggang LI To: hal@dev.mellanox.co.il Cc: linux-rdma@vger.kernel.org, Honggang Li Subject: [PATCH 4/5] osm_qos_parser_y.y: fix resource leak Date: Mon, 27 Aug 2018 14:42:32 +0800 Message-Id: <20180827064233.3218-4-honli@redhat.com> In-Reply-To: <20180827064233.3218-3-honli@redhat.com> References: <20180827064233.3218-1-honli@redhat.com> <20180827064233.3218-2-honli@redhat.com> <20180827064233.3218-3-honli@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.1]); Mon, 27 Aug 2018 06:43:00 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.1]); Mon, 27 Aug 2018 06:43:00 +0000 (UTC) for IP:'10.11.54.6' DOMAIN:'int-mx06.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'honli@redhat.com' RCPT:'' 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 From: Honggang Li Issue was found by Coverity. Error: RESOURCE_LEAK (CWE-772): [#def11] opensm-3.3.20/opensm/osm_qos_parser_y.y:996: alloc_fn: Storage is returned from allocation function "malloc". opensm-3.3.20/opensm/osm_qos_parser_y.y:996: var_assign: Assigning: "range_arr" = storage returned from "malloc(8UL)". opensm-3.3.20/opensm/osm_qos_parser_y.y:1006: noescape: Resource "range_arr" is not freed or pointed-to in "__validate_pkeys". opensm-3.3.20/opensm/osm_qos_parser_y.y:3111:42: noescape: "__validate_pkeys(uint64_t **, unsigned int, boolean_t)" does not free or save its parameter "range_arr". opensm-3.3.20/opensm/osm_qos_parser_y.y:1007: leaked_storage: Variable "range_arr" going out of scope leaks the storage it points to. |# 1005| */ |# 1006| if (__validate_pkeys(range_arr, 1, TRUE)) |# 1007|-> return 1; |# 1008| |# 1009| p_current_qos_match_rule->pkey_range_arr = range_arr; Signed-off-by: Honggang Li --- opensm/osm_qos_parser_y.y | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/opensm/osm_qos_parser_y.y b/opensm/osm_qos_parser_y.y index e0f6580c..12466956 100644 --- a/opensm/osm_qos_parser_y.y +++ b/opensm/osm_qos_parser_y.y @@ -1003,8 +1003,11 @@ qos_ulp: TK_ULP_DEFAULT single_number { * we still need to validate it by checking that it has * at least two full members. Otherwise IPoIB won't work. */ - if (__validate_pkeys(range_arr, 1, TRUE)) + if (__validate_pkeys(range_arr, 1, TRUE)) { + free(range_arr[0]); + free(range_arr); return 1; + } p_current_qos_match_rule->pkey_range_arr = range_arr; p_current_qos_match_rule->pkey_range_len = 1; From patchwork Mon Aug 27 06:42:33 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Honggang LI X-Patchwork-Id: 10576413 X-Patchwork-Delegate: hal@mellanox.com 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 94B28174A for ; Mon, 27 Aug 2018 06:43:05 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 883612971F for ; Mon, 27 Aug 2018 06:43:05 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7C98829721; Mon, 27 Aug 2018 06:43:05 +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 10B552971F for ; Mon, 27 Aug 2018 06:43:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727100AbeH0K2U (ORCPT ); Mon, 27 Aug 2018 06:28:20 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:55832 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726874AbeH0K2U (ORCPT ); Mon, 27 Aug 2018 06:28:20 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 17DCC40216E9; Mon, 27 Aug 2018 06:43:03 +0000 (UTC) Received: from lhg.nay.redhat.com (unknown [10.66.129.124]) by smtp.corp.redhat.com (Postfix) with ESMTP id 75D772166B41; Mon, 27 Aug 2018 06:43:01 +0000 (UTC) From: Honggang LI To: hal@dev.mellanox.co.il Cc: linux-rdma@vger.kernel.org, Honggang Li Subject: [PATCH 5/5] osm_ucast_nue.c: fix resource leak in nue_create_context Date: Mon, 27 Aug 2018 14:42:33 +0800 Message-Id: <20180827064233.3218-5-honli@redhat.com> In-Reply-To: <20180827064233.3218-4-honli@redhat.com> References: <20180827064233.3218-1-honli@redhat.com> <20180827064233.3218-2-honli@redhat.com> <20180827064233.3218-3-honli@redhat.com> <20180827064233.3218-4-honli@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.5]); Mon, 27 Aug 2018 06:43:03 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.5]); Mon, 27 Aug 2018 06:43:03 +0000 (UTC) for IP:'10.11.54.6' DOMAIN:'int-mx06.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'honli@redhat.com' RCPT:'' 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 From: Honggang Li Issue was found by Coverity. Error: RESOURCE_LEAK (CWE-772): opensm-3.3.20/opensm/osm_ucast_nue.c:3159: alloc_fn: Storage is returned from allocation function "malloc". opensm-3.3.20/opensm/osm_ucast_nue.c:3159: var_assign: Assigning: "nue_ctx" = storage returned from "malloc(336UL)". opensm-3.3.20/opensm/osm_ucast_nue.c:3164: noescape: Resource "nue_ctx" is not freed or pointed-to in "create_context". opensm-3.3.20/opensm/osm_ucast_nue.c:3109:43: noescape: "create_context(nue_context_t *)" does not free or save its parameter "nue_ctx". opensm-3.3.20/opensm/osm_ucast_nue.c:3166: leaked_storage: Variable "nue_ctx" going out of scope leaks the storage it points to. |# 3164| err = create_context(nue_ctx); |# 3165| if (err) |# 3166|-> return NULL; |# 3167| } else { |# 3168| OSM_LOG(osm->sm.ucast_mgr.p_log, OSM_LOG_ERROR, Signed-off-by: Honggang Li --- opensm/osm_ucast_nue.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/opensm/osm_ucast_nue.c b/opensm/osm_ucast_nue.c index 13684738..0ef84ebc 100644 --- a/opensm/osm_ucast_nue.c +++ b/opensm/osm_ucast_nue.c @@ -3162,8 +3162,10 @@ static nue_context_t *nue_create_context(const osm_opensm_t * osm, nue_ctx->routing_type = routing_type; nue_ctx->mgr = (osm_ucast_mgr_t *) & (osm->sm.ucast_mgr); err = create_context(nue_ctx); - if (err) + if (err) { + free(nue_ctx); return NULL; + } } else { OSM_LOG(osm->sm.ucast_mgr.p_log, OSM_LOG_ERROR, "ERR NUE01: cannot allocate memory for nue_ctx\n");