From patchwork Wed Jun 20 16:21:29 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kenneth Dsouza X-Patchwork-Id: 10477853 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 DDCCB60210 for ; Wed, 20 Jun 2018 16:21:38 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CF40628F3F for ; Wed, 20 Jun 2018 16:21:38 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CE1BC28F41; Wed, 20 Jun 2018 16:21:38 +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=-7.9 required=2.0 tests=BAYES_00, MAILING_LIST_MULTI, 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 546CD28F4A for ; Wed, 20 Jun 2018 16:21:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754244AbeFTQVg (ORCPT ); Wed, 20 Jun 2018 12:21:36 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:54048 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1754230AbeFTQVf (ORCPT ); Wed, 20 Jun 2018 12:21:35 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id F15C040201A2 for ; Wed, 20 Jun 2018 16:21:34 +0000 (UTC) Received: from localhost.localdomain.com (unknown [10.76.1.177]) by smtp.corp.redhat.com (Postfix) with ESMTP id B5BCC2156700; Wed, 20 Jun 2018 16:21:33 +0000 (UTC) From: Kenneth Dsouza To: linux-nfs@vger.kernel.org Cc: steved@redhat.com, sorenson@redhat.com Subject: [PATCH] nfs-utils: Fix minor memory leaks before return. Date: Wed, 20 Jun 2018 21:51:29 +0530 Message-Id: <20180620162129.12692-1-kdsouza@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.6]); Wed, 20 Jun 2018 16:21:35 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.6]); Wed, 20 Jun 2018 16:21:35 +0000 (UTC) for IP:'10.11.54.6' DOMAIN:'int-mx06.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'kdsouza@redhat.com' RCPT:'' 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 Signed-off-by: Kenneth D'souza Signed-off-by: Frank Sorenson --- support/junction/path.c | 4 +++- support/nfsidmap/nfsidmap_common.c | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/support/junction/path.c b/support/junction/path.c index 68a1d13..e74e4c4 100644 --- a/support/junction/path.c +++ b/support/junction/path.c @@ -326,8 +326,10 @@ nsdb_posix_to_path_array(const char *pathname, char ***path_array) break; next = strchrnul(component, '/'); length = (size_t)(next - component); - if (length > 255) + if (length > 255) { + nsdb_free_string_array(result); return FEDFS_ERR_SVRFAULT; + } result[i] = strndup(component, length); if (result[i] == NULL) { diff --git a/support/nfsidmap/nfsidmap_common.c b/support/nfsidmap/nfsidmap_common.c index 5242c7e..f89b82e 100644 --- a/support/nfsidmap/nfsidmap_common.c +++ b/support/nfsidmap/nfsidmap_common.c @@ -57,8 +57,10 @@ struct conf_list *get_local_realms(void) return NULL; node->field = calloc(1, NFS4_MAX_DOMAIN_LEN); - if (node->field == NULL) + if (node->field == NULL) { + free(node); return NULL; + } nfs4_get_default_domain(NULL, node->field, NFS4_MAX_DOMAIN_LEN); toupper_str(node->field);