From patchwork Thu Jun 14 16:28:25 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kenneth Dsouza X-Patchwork-Id: 10464859 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 0EF4160348 for ; Thu, 14 Jun 2018 16:28:30 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F1D2A287C7 for ; Thu, 14 Jun 2018 16:28:29 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E4762287B1; Thu, 14 Jun 2018 16:28:29 +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 4EBE2287B1 for ; Thu, 14 Jun 2018 16:28:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755308AbeFNQ22 (ORCPT ); Thu, 14 Jun 2018 12:28:28 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:37408 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1755252AbeFNQ22 (ORCPT ); Thu, 14 Jun 2018 12:28:28 -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 A7C0140122BD for ; Thu, 14 Jun 2018 16:28:27 +0000 (UTC) Received: from localhost.localdomain.com (unknown [10.76.1.177]) by smtp.corp.redhat.com (Postfix) with ESMTP id B6DB8201E8ED; Thu, 14 Jun 2018 16:28:26 +0000 (UTC) From: Kenneth Dsouza To: linux-nfs@vger.kernel.org Cc: steved@redhat.com Subject: [PATCH] nfs-utils: Fix a minor memory leak in generate_mount_unit and generate_target. Date: Thu, 14 Jun 2018 21:58:25 +0530 Message-Id: <20180614162825.25676-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.5]); Thu, 14 Jun 2018 16:28:27 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.5]); Thu, 14 Jun 2018 16:28:27 +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 Free allocated memory for path before return. Signed-off-by: Kenneth D'souza --- systemd/rpc-pipefs-generator.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/systemd/rpc-pipefs-generator.c b/systemd/rpc-pipefs-generator.c index 6e1d69c..0b5da11 100644 --- a/systemd/rpc-pipefs-generator.c +++ b/systemd/rpc-pipefs-generator.c @@ -35,7 +35,10 @@ static int generate_mount_unit(const char *pipefs_path, const char *pipefs_unit, sprintf(path, "%s/%s", dirname, pipefs_unit); f = fopen(path, "w"); if (!f) + { + free(path); return 1; + } fprintf(f, "# Automatically generated by rpc-pipefs-generator\n\n[Unit]\n"); fprintf(f, "Description=RPC Pipe File System\n"); @@ -48,6 +51,7 @@ static int generate_mount_unit(const char *pipefs_path, const char *pipefs_unit, fprintf(f, "Type=rpc_pipefs\n"); fclose(f); + free(path); return 0; } @@ -76,12 +80,16 @@ int generate_target(char *pipefs_path, const char *dirname) strcat(path, filebase); f = fopen(path, "w"); if (!f) + { + free(path); return 1; + } fprintf(f, "# Automatically generated by rpc-pipefs-generator\n\n[Unit]\n"); fprintf(f, "Requires=%s\n", pipefs_unit); fprintf(f, "After=%s\n", pipefs_unit); fclose(f); + free(path); return 0; }