From patchwork Thu Jan 8 12:49:59 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hal Rosenstock X-Patchwork-Id: 5592421 X-Patchwork-Delegate: hal@mellanox.com Return-Path: X-Original-To: patchwork-linux-rdma@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id D4BDB9F357 for ; Thu, 8 Jan 2015 12:50:06 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id EB44B2038A for ; Thu, 8 Jan 2015 12:50:05 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 1D2EE20389 for ; Thu, 8 Jan 2015 12:50:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754128AbbAHMuD (ORCPT ); Thu, 8 Jan 2015 07:50:03 -0500 Received: from mail-wi0-f181.google.com ([209.85.212.181]:47959 "EHLO mail-wi0-f181.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753240AbbAHMuD (ORCPT ); Thu, 8 Jan 2015 07:50:03 -0500 Received: by mail-wi0-f181.google.com with SMTP id r20so3039112wiv.2 for ; Thu, 08 Jan 2015 04:50:01 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:message-id:date:from:user-agent:mime-version:to :cc:subject:content-type:content-transfer-encoding; bh=p/S3HGxzekrTt3aJNkWSvczHQLCjmo8iYiSpT4kqfU0=; b=beJC4+RCMb4NYRlKsmQ4ds2NVYbDqFRqILe+ezKjGBO6bT7eeMoXTu2cGfLVArtE6M AqCg/SJvomXIh+rKDnne7b1ZaJ6gkUaZXD5z8KsZjeFoU5AdGvSwY+CXAjhEqyDcgTUr FILkOdcZVjPa6usnzFe5FSy6R+cMh40nWsmGCcaW+1/eu5zHCg8rz/RD5RQtUR4lQPZJ +wXAMBZlNpHPZKjzaFeq/RKg22lRG/NMW1kbl03mlYD2iw7yzxN9M1FKK0NkQeZNDUOD 8ZGYDc9KJ2zoj5safduiRmVV5upsQJLDjRey32u1zX1DtEFJwRqqLn13yBIgRwkvA7L7 D26w== X-Gm-Message-State: ALoCoQl/59w/nOscgIebhVtTE+UcBT/wbDmxD1YE51lO7nuiEi053uVvqJU9HQLWAf+s503Hskmy X-Received: by 10.194.174.3 with SMTP id bo3mr18709671wjc.98.1420721401826; Thu, 08 Jan 2015 04:50:01 -0800 (PST) Received: from [192.168.1.102] (c-98-229-118-119.hsd1.ma.comcast.net. [98.229.118.119]) by mx.google.com with ESMTPSA id kn7sm6003350wjc.45.2015.01.08.04.50.00 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 08 Jan 2015 04:50:01 -0800 (PST) Message-ID: <54AE7CF7.5000805@dev.mellanox.co.il> Date: Thu, 08 Jan 2015 07:49:59 -0500 From: Hal Rosenstock User-Agent: Mozilla/5.0 (Windows NT 6.1; rv:9.0) Gecko/20111222 Thunderbird/9.0.1 MIME-Version: 1.0 To: "linux-rdma (linux-rdma@vger.kernel.org)" CC: Daniel Klein Subject: [PATCH opensm 4/5] osm_ucast_cache.c: Rewrite p_sw->lft allocation in osm_ucast_cache_process Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Daniel Klein Performed the following changes in the code that allocates p_sw->lft buffer in osm_ucast_cache_process: 1. remove allocation of p_sw->new_lft and replace it with assert that checks that p_sw->is already allocated. p_sw->new_lft, should already be allocated and defined by either ucast_cache or the ucast_mgr. 2. replace p_sw->need_update check, with checking if p_sw->lft is not allocated. p_sw->need update could indicate the switches LFT are not updated, and when p_sw->lft is already allocated, it cause memory leak. Signed-off-by: Daniel Klein Signed-off-by: Hal Rosenstock --- opensm/osm_ucast_cache.c | 9 ++------- 1 files changed, 2 insertions(+), 7 deletions(-) diff --git a/opensm/osm_ucast_cache.c b/opensm/osm_ucast_cache.c index 2fab643..3caf318 100644 --- a/opensm/osm_ucast_cache.c +++ b/opensm/osm_ucast_cache.c @@ -1040,13 +1040,8 @@ int osm_ucast_cache_process(osm_ucast_mgr_t * p_mgr) for (item = cl_qmap_head(tbl); item != cl_qmap_end(tbl); item = cl_qmap_next(item)) { p_sw = (osm_switch_t *) item; - - if (p_sw->need_update) { - if (!p_sw->new_lft) - /* no new routing was recently calculated for this - switch, but the LFT needs to be updated anyway */ - p_sw->new_lft = p_sw->lft; - + CL_ASSERT(p_sw->new_lft); + if (!p_sw->lft) { lft_size = (p_sw->max_lid_ho / IB_SMP_DATA_SIZE + 1) * IB_SMP_DATA_SIZE; p_sw->lft = malloc(lft_size);