From patchwork Tue Sep 7 15:11:01 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yevgeny Kliteynik X-Patchwork-Id: 161191 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id o87FBGgo001855 for ; Tue, 7 Sep 2010 15:11:17 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757278Ab0IGPLQ (ORCPT ); Tue, 7 Sep 2010 11:11:16 -0400 Received: from mail.mellanox.co.il ([194.90.237.43]:58216 "EHLO mellanox.co.il" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1757017Ab0IGPLP (ORCPT ); Tue, 7 Sep 2010 11:11:15 -0400 Received: from Internal Mail-Server by MTLPINE2 (envelope-from kliteyn@mellanox.co.il) with SMTP; 7 Sep 2010 18:10:33 +0300 Received: from [10.4.1.29] (10.4.1.29) by mtlmail01.mtl.com (10.0.8.12) with Microsoft SMTP Server id 8.2.254.0; Tue, 7 Sep 2010 18:11:11 +0300 Message-ID: <4C865605.4050702@mellanox.co.il> Date: Tue, 7 Sep 2010 18:11:01 +0300 From: Yevgeny Kliteynik Reply-To: kliteyn@dev.mellanox.co.il User-Agent: Thunderbird 1.5.0.5 (X11/20060719) MIME-Version: 1.0 To: Sasha Khapyorsky , Linux RDMA Subject: [PATCH] opensm/osm_ucast_ftree.c: fix small memory leak in error path Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter1.kernel.org [140.211.167.41]); Tue, 07 Sep 2010 15:11:17 +0000 (UTC) diff --git a/opensm/opensm/osm_ucast_ftree.c b/opensm/opensm/osm_ucast_ftree.c index 88ea344..fb46d0f 100644 --- a/opensm/opensm/osm_ucast_ftree.c +++ b/opensm/opensm/osm_ucast_ftree.c @@ -791,8 +791,10 @@ static ftree_hca_t *hca_create(IN osm_node_t * p_osm_node) p_hca->up_port_groups = (ftree_port_group_t **) malloc(osm_node_get_num_physp(p_hca->p_osm_node) * sizeof(ftree_port_group_t *)); - if (!p_hca->up_port_groups) + if (!p_hca->up_port_groups) { + free(p_hca); return NULL; + } p_hca->up_port_groups_num = 0; return p_hca; }