From patchwork Fri Jul 29 05:03:36 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: NeilBrown X-Patchwork-Id: 9252085 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id E2C58601C0 for ; Fri, 29 Jul 2016 05:05:11 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D68B427F46 for ; Fri, 29 Jul 2016 05:05:11 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CB2D427F96; Fri, 29 Jul 2016 05:05:11 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 81D3927F46 for ; Fri, 29 Jul 2016 05:05:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751304AbcG2FFK (ORCPT ); Fri, 29 Jul 2016 01:05:10 -0400 Received: from mx2.suse.de ([195.135.220.15]:35117 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751055AbcG2FFI (ORCPT ); Fri, 29 Jul 2016 01:05:08 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay1.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 90A5DAAF2; Fri, 29 Jul 2016 05:05:07 +0000 (UTC) From: NeilBrown To: Steve Dickson Date: Fri, 29 Jul 2016 15:03:36 +1000 Subject: [PATCH 5/7] mount: fix memory leak in v4root_add_parents Cc: "J. Bruce Fields" , Linux NFS Mailing list Message-ID: <146976861678.20186.788066493232715792.stgit@noble> In-Reply-To: <146976807524.20186.8871903418718212567.stgit@noble> References: <146976807524.20186.8871903418718212567.stgit@noble> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP If pseudofs_update failed, we weren't freeing 'path'. Signed-off-by: NeilBrown --- utils/mountd/v4root.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) -- To unsubscribe from this list: send the line "unsubscribe linux-nfs" 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/utils/mountd/v4root.c b/utils/mountd/v4root.c index d52172592823..f978f4ceef01 100644 --- a/utils/mountd/v4root.c +++ b/utils/mountd/v4root.c @@ -152,6 +152,7 @@ static int v4root_add_parents(nfs_export *exp) char *hostname = exp->m_export.e_hostname; char *path; char *ptr; + int ret = 0; path = strdup(exp->m_export.e_path); if (!path) { @@ -160,19 +161,18 @@ static int v4root_add_parents(nfs_export *exp) return -ENOMEM; } for (ptr = path; ptr; ptr = strchr(ptr, '/')) { - int ret; char saved; saved = *ptr; *ptr = '\0'; ret = pseudofs_update(hostname, *path ? path : "/", exp); if (ret) - return ret; + break; *ptr = saved; ptr++; } free(path); - return 0; + return ret; } /*