From patchwork Tue Aug 20 14:28:49 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hal Rosenstock X-Patchwork-Id: 2847134 X-Patchwork-Delegate: hal@mellanox.com Return-Path: X-Original-To: patchwork-linux-rdma@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 656F3BF546 for ; Tue, 20 Aug 2013 14:29:01 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id BE319204C9 for ; Tue, 20 Aug 2013 14:28:56 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 6183E204AF for ; Tue, 20 Aug 2013 14:28:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751343Ab3HTO2x (ORCPT ); Tue, 20 Aug 2013 10:28:53 -0400 Received: from mail-ee0-f41.google.com ([74.125.83.41]:38858 "EHLO mail-ee0-f41.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751045Ab3HTO2x (ORCPT ); Tue, 20 Aug 2013 10:28:53 -0400 Received: by mail-ee0-f41.google.com with SMTP id d17so243910eek.14 for ; Tue, 20 Aug 2013 07:28:52 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-gm-message-state:message-id:date:from:user-agent:mime-version:to :cc:subject:content-type:content-transfer-encoding; bh=CaHWyDZJ9q+83ytP7ZtivY6zx15bpkbfHVZKKKBtcYg=; b=M3KFo303bWw15B3n+zywrX4FqEHefLyxxTG4OQFU8o/yeOwpA9JFDXC+A7A5uROYTI JpfgR5+uGptyH2SQbiVoxRfl+ixNVW4NFC3iaaPvmFxSZImwKmwDZixjquXrqYv0Cm0q CAwhzKvpBXcIvjSbVjiVIhxQh2t0D6buzy2wovILtDzCEuU9OhQ/hF1OZMbKKCzC0Shc TGs1ERyEP6byc5loBl8sZhj+KRXmBO3gtVWWem+2fZUfFX8jllBZi1Kpe9GpIJA7Kw9O qz0y+9vW/7YR6kuDQ7bluXed/qfviXv96t8XOs691fVybQtnqgEPEqgoe2yvaNqyOYWb stBQ== X-Gm-Message-State: ALoCoQkJuvIEb6B8kXREAl7rtN/vt+q2ahkLxgBthLvuI2BYzY4yLvgrvrqavOEJUpjOidR9g/qT X-Received: by 10.15.67.131 with SMTP id u3mr2734332eex.34.1377008932014; Tue, 20 Aug 2013 07:28:52 -0700 (PDT) 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 t6sm2768203eel.12.1969.12.31.16.00.00 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 20 Aug 2013 07:28:51 -0700 (PDT) Message-ID: <52137D21.1080806@dev.mellanox.co.il> Date: Tue, 20 Aug 2013 10:28:49 -0400 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: Bart Van Assche , Vladimir Koushnir Subject: [PATCH v2 opensm] osm_subnet.c: Fix memory leak caused by commit dc0760cb8088fbe079e19682570a884ba01e94ff Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Spam-Status: No, score=-9.7 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, 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: Vladimir Koushnir double strdup for p_opt->dump_files_dir is causing memory leak Approach from Bart Van Assche Signed-off-by: Vladimir Koushnir Signed-off-by: Hal Rosenstock --- Change since v1: Eliminate cast by doing separate strdup -- To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/opensm/osm_subnet.c b/opensm/osm_subnet.c index 7ab1671..d0835b9 100644 --- a/opensm/osm_subnet.c +++ b/opensm/osm_subnet.c @@ -1499,7 +1499,8 @@ void osm_subn_set_default_opt(IN osm_subn_opt_t * p_opt) p_opt->dump_files_dir = getenv("OSM_TMP_DIR"); if (!p_opt->dump_files_dir || !(*p_opt->dump_files_dir)) p_opt->dump_files_dir = strdup(OSM_DEFAULT_TMP_DIR); - p_opt->dump_files_dir = strdup(p_opt->dump_files_dir); + else + p_opt->dump_files_dir = strdup(p_opt->dump_files_dir); p_opt->log_file = strdup(OSM_DEFAULT_LOG_FILE); p_opt->log_max_size = 0; p_opt->partition_config_file = strdup(OSM_DEFAULT_PARTITION_CONFIG_FILE);