Return-Path: Received: from mx1.redhat.com ([209.132.183.28]:37902 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S966514AbeFSQ4L (ORCPT ); Tue, 19 Jun 2018 12:56:11 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id C66365F736 for ; Tue, 19 Jun 2018 16:56:11 +0000 (UTC) Subject: Re: [PATCH] nfs-utils: Fix a minor memory leak in generate_mount_unit and generate_target. To: Kenneth Dsouza , linux-nfs@vger.kernel.org References: <20180614162825.25676-1-kdsouza@redhat.com> From: Steve Dickson Message-ID: Date: Tue, 19 Jun 2018 12:56:10 -0400 MIME-Version: 1.0 In-Reply-To: <20180614162825.25676-1-kdsouza@redhat.com> Content-Type: text/plain; charset=utf-8 Sender: linux-nfs-owner@vger.kernel.org List-ID: On 06/14/2018 12:28 PM, Kenneth Dsouza wrote: > Free allocated memory for path before return. > Signed-off-by: Kenneth D'souza Committed.... steved. > --- > 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; > } >