From patchwork Sun May 11 21:29:37 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Lever X-Patchwork-Id: 347828 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from aserp1040.oracle.com (aserp1040.oracle.com [141.146.126.69]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 12652140083 for ; Mon, 12 May 2014 07:29:48 +1000 (EST) Received: from acsinet22.oracle.com (acsinet22.oracle.com [141.146.126.238]) by aserp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id s4BLTjZ5007765 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Sun, 11 May 2014 21:29:46 GMT Received: from oss.oracle.com (oss-external.oracle.com [137.254.96.51]) by acsinet22.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id s4BLTjQW015302 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Sun, 11 May 2014 21:29:45 GMT Received: from localhost ([127.0.0.1] helo=oss.oracle.com) by oss.oracle.com with esmtp (Exim 4.63) (envelope-from ) id 1WjbJZ-0004Dh-J3; Sun, 11 May 2014 14:29:45 -0700 Received: from acsinet22.oracle.com ([141.146.126.238]) by oss.oracle.com with esmtp (Exim 4.63) (envelope-from ) id 1WjbJU-0004DL-B0 for fedfs-utils-devel@oss.oracle.com; Sun, 11 May 2014 14:29:40 -0700 Received: from userp1030.oracle.com (userp1030.oracle.com [156.151.31.80]) by acsinet22.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id s4BLTdC9015259 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Sun, 11 May 2014 21:29:40 GMT Received: from mail-ie0-f181.google.com (mail-ie0-f181.google.com [209.85.223.181]) by userp1030.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id s4BLTcpL017943 (version=TLSv1/SSLv3 cipher=RC4-SHA bits=128 verify=OK) for ; Sun, 11 May 2014 21:29:39 GMT Authentication-Results: userp1030.oracle.com; dkim=pass reason="2048-bit key" header.d=gmail.com header.i=@gmail.com header.b=m6iN1XJM Received: by mail-ie0-f181.google.com with SMTP id y20so6189406ier.40 for ; Sun, 11 May 2014 14:29:38 -0700 (PDT) X-Received: by 10.50.49.109 with SMTP id t13mr36189018ign.2.1399843778403; Sun, 11 May 2014 14:29:38 -0700 (PDT) Received: from seurat.1015granger.net ([2604:8800:100:81fc:20c:29ff:fe44:ec31]) by mx.google.com with ESMTPSA id hi8sm16898904igb.8.2014.05.11.14.29.37 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 11 May 2014 14:29:38 -0700 (PDT) To: fedfs-utils-devel@oss.oracle.com From: Chuck Lever Date: Sun, 11 May 2014 17:29:37 -0400 Message-ID: <20140511212937.13852.77172.stgit@seurat.1015granger.net> In-Reply-To: <20140511212416.13852.92639.stgit@seurat.1015granger.net> References: <20140511212416.13852.92639.stgit@seurat.1015granger.net> User-Agent: StGit/0.16 MIME-Version: 1.0 X-Flow-Control-Info: class=Pass-to-MM reputation=ipRisk-All ip=209.85.223.181 ct-class=R5 ct-vol1=-95 ct-vol2=8 ct-vol3=7 ct-risk=54 ct-spam1=87 ct-spam2=7 ct-bulk=6 rcpts=1 size=2021 X-Sendmail-CM-Score: 0.00% X-Sendmail-CM-Analysis: v=2.1 cv=CYoxutbl c=1 sm=1 tr=0 a=gpi+er6/4TN47Q6KBifQ7Q==:117 a=dzsqy3y4QnMA:10 a=VlnsAdckvn4A:10 a=dPGociXpb70A:10 a=IkcTkHD0fZMA:10 a=xqWC_Br6kY4A:10 a=yPCof4ZbAAAA:8 a=Lb1rMZzfAAAA:8 a=1XWaLZrsAAAA:8 a=5StmUG--vG5A-8UeQqsA:9 a=QEXdDO 2ut3YA:10 a=7DSvI1NPTFQA:10 X-Sendmail-CT-RefID: str=0001.0A090201.536FEBC3.0045, ss=1, re=0.000, recu=0.000, reip=0.000, cl=1, cld=1, fgs=0 X-Sendmail-CT-Classification: not spam Subject: [fedfs-utils] [PATCH 11/17] fedfsc: Fix memory leak in fedfs-lookup-replication X-BeenThere: fedfs-utils-devel@oss.oracle.com X-Mailman-Version: 2.1.9 Precedence: list Reply-To: fedfs-utils Developers List-Id: fedfs-utils Developers List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: fedfs-utils-devel-bounces@oss.oracle.com Errors-To: fedfs-utils-devel-bounces@oss.oracle.com X-Source-IP: acsinet22.oracle.com [141.146.126.238] Ensure "fsls" and "fsn" are freed before returning. Fixes: b7c5e005319bdefa93d2158c9bd5de67c03e6a60 Signed-off-by: Chuck Lever --- src/fedfsc/fedfs-lookup-replication.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/fedfsc/fedfs-lookup-replication.c b/src/fedfsc/fedfs-lookup-replication.c index bfa04e3..e258f8b 100644 --- a/src/fedfsc/fedfs-lookup-replication.c +++ b/src/fedfsc/fedfs-lookup-replication.c @@ -142,13 +142,13 @@ static int fedfs_lookup_replication_try(admin_t host, char * const *path_array, int request) { - struct admin_fsl *fsls; - struct admin_fsn *fsn; + struct admin_fsl *fsls = NULL; + struct admin_fsn *fsn = NULL; int status, err; + status = EXIT_FAILURE; switch (request) { case 0: - fsls = NULL; err = admin_lookup_replication_none(host, path_array, &fsn); break; case 1: @@ -159,9 +159,11 @@ fedfs_lookup_replication_try(admin_t host, char * const *path_array, err = admin_lookup_replication_nsdb(host, path_array, &fsn, &fsls); break; + default: + xlog(L_ERROR, "Unrecognized request"); + goto out; } - status = EXIT_FAILURE; switch (err) { case 0: break; @@ -185,23 +187,23 @@ fedfs_lookup_replication_try(admin_t host, char * const *path_array, printf("NSDB: %s:%u\n", fsn->af_nsdb.an_hostname, fsn->af_nsdb.an_port); - admin_free_fsn(fsn); - if (request > 0) { + if (request > 0) fedfs_lookup_replication_print_fsls(fsls); - admin_free_fsls(fsls); - } status = EXIT_SUCCESS; break; case FEDFS_ERR_NSDB_LDAP_VAL: fprintf(stderr, "LDAP result code (%d): %s\n", admin_ldaperr(host), ldap_err2string(admin_ldaperr(host))); + break; case FEDFS_ERR_NSDB_PARAMS: printf("No connection parameters found\n"); break; default: nsdb_print_fedfsstatus(admin_status(host)); } + admin_free_fsls(fsls); + admin_free_fsn(fsn); out: return status;