All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] nfs-utils: Fix a minor memory leak in generate_mount_unit and generate_target.
@ 2018-06-14 16:28 Kenneth Dsouza
  2018-06-19 16:56 ` Steve Dickson
  0 siblings, 1 reply; 2+ messages in thread
From: Kenneth Dsouza @ 2018-06-14 16:28 UTC (permalink / raw)
  To: linux-nfs; +Cc: steved

Free allocated memory for path before return.
Signed-off-by: Kenneth D'souza <kdsouza@redhat.com>
---
 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;
 }
-- 
2.14.3


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] nfs-utils: Fix a minor memory leak in generate_mount_unit and generate_target.
  2018-06-14 16:28 [PATCH] nfs-utils: Fix a minor memory leak in generate_mount_unit and generate_target Kenneth Dsouza
@ 2018-06-19 16:56 ` Steve Dickson
  0 siblings, 0 replies; 2+ messages in thread
From: Steve Dickson @ 2018-06-19 16:56 UTC (permalink / raw)
  To: Kenneth Dsouza, linux-nfs



On 06/14/2018 12:28 PM, Kenneth Dsouza wrote:
> Free allocated memory for path before return.
> Signed-off-by: Kenneth D'souza <kdsouza@redhat.com>
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;
>  }
> 

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2018-06-19 16:56 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-06-14 16:28 [PATCH] nfs-utils: Fix a minor memory leak in generate_mount_unit and generate_target Kenneth Dsouza
2018-06-19 16:56 ` Steve Dickson

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.