From patchwork Fri Nov 6 18:14:24 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Al Chu X-Patchwork-Id: 58083 Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id nA6IEN6L007643 for ; Fri, 6 Nov 2009 18:14:26 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758858AbZKFSOT (ORCPT ); Fri, 6 Nov 2009 13:14:19 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1759460AbZKFSOT (ORCPT ); Fri, 6 Nov 2009 13:14:19 -0500 Received: from nspiron-1.llnl.gov ([128.115.41.81]:61159 "EHLO nspiron-1.llnl.gov" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1759429AbZKFSOT (ORCPT ); Fri, 6 Nov 2009 13:14:19 -0500 X-Attachments: 0002-fix-potential-segfault-in-ibnd_node_t-destroy-path.patch Received: from auk31.llnl.gov (HELO [134.9.93.159]) ([134.9.93.159]) by nspiron-1.llnl.gov with ESMTP; 06 Nov 2009 10:14:24 -0800 Subject: [infiniband-diags] [PATCH 2/2] fix potential segfault in ibnd_node_t destroy path From: Al Chu Reply-To: chu11@llnl.gov To: Sasha Khapyorsky Cc: linux-rdma@vger.kernel.org Date: Fri, 06 Nov 2009 10:14:24 -0800 Message-Id: <1257531264.18550.70.camel@auk31.llnl.gov> Mime-Version: 1.0 X-Mailer: Evolution 2.12.3 (2.12.3-19.el5) Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org diff --git a/infiniband-diags/libibnetdisc/src/ibnetdisc.c b/infiniband-diags/libibnetdisc/src/ibnetdisc.c index 62dff93..7ce9a54 100644 --- a/infiniband-diags/libibnetdisc/src/ibnetdisc.c +++ b/infiniband-diags/libibnetdisc/src/ibnetdisc.c @@ -605,10 +605,12 @@ static void destroy_node(ibnd_node_t * node) { int p = 0; - for (p = 0; p <= node->numports; p++) { - free(node->ports[p]); + if (node->ports) { + for (p = 0; p <= node->numports; p++) { + free(node->ports[p]); + } + free(node->ports); } - free(node->ports); free(node); }