* [PATCH] nfs-server-generator: fix a potential memory leak issue
@ 2017-04-09 16:12 ChunYu Wang
2017-04-09 18:33 ` Steve Dickson
0 siblings, 1 reply; 3+ messages in thread
From: ChunYu Wang @ 2017-04-09 16:12 UTC (permalink / raw)
To: steved; +Cc: linux-nfs, yoyang, jiyin, ChunYu Wang
Signed-off-by: ChunYu Wang <chunwang@redhat.com>
---
Fix a potential memory leak issue caused by unfree pathname 'path'.
systemd/nfs-server-generator.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/systemd/nfs-server-generator.c b/systemd/nfs-server-generator.c
index 4aa6509..441cec5 100644
--- a/systemd/nfs-server-generator.c
+++ b/systemd/nfs-server-generator.c
@@ -139,6 +139,7 @@ int main(int argc, char *argv[])
strcat(path, filebase);
f = fopen(path, "w");
if (!f)
+ free(path);
exit(1);
fprintf(f, "# Automatically generated by nfs-server-generator\n\n[Unit]\n");
--
2.7.4
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] nfs-server-generator: fix a potential memory leak issue
2017-04-09 16:12 [PATCH] nfs-server-generator: fix a potential memory leak issue ChunYu Wang
@ 2017-04-09 18:33 ` Steve Dickson
2017-04-10 3:09 ` ChunYu Wang
0 siblings, 1 reply; 3+ messages in thread
From: Steve Dickson @ 2017-04-09 18:33 UTC (permalink / raw)
To: ChunYu Wang; +Cc: linux-nfs, yoyang, jiyin
On 04/09/2017 12:12 PM, ChunYu Wang wrote:
> Signed-off-by: ChunYu Wang <chunwang@redhat.com>
> ---
> Fix a potential memory leak issue caused by unfree pathname 'path'.
>
> systemd/nfs-server-generator.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/systemd/nfs-server-generator.c b/systemd/nfs-server-generator.c
> index 4aa6509..441cec5 100644
> --- a/systemd/nfs-server-generator.c
> +++ b/systemd/nfs-server-generator.c
> @@ -139,6 +139,7 @@ int main(int argc, char *argv[])
> strcat(path, filebase);
> f = fopen(path, "w");
> if (!f)
> + free(path);
> exit(1);
First of all you need some '{' '}' so the process will not
always exit when f != NULL...
Secondly dead process don't leak memory. :-) They don't leak anything... they are died! ;-)
steved.
> fprintf(f, "# Automatically generated by nfs-server-generator\n\n[Unit]\n");
>
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] nfs-server-generator: fix a potential memory leak issue
2017-04-09 18:33 ` Steve Dickson
@ 2017-04-10 3:09 ` ChunYu Wang
0 siblings, 0 replies; 3+ messages in thread
From: ChunYu Wang @ 2017-04-10 3:09 UTC (permalink / raw)
To: Steve Dickson; +Cc: Jianhong Yin, Yongcheng Yang, linux-nfs
En, yes,
Thanks for reviewing and reminding, it is my fault [ : ( ].
Valgrind did not notice me about the syntax rationality, but it's my duty.
Get down to learn, and thanks a lot.
Regards,
ChunYu Wang
On Mon, Apr 10, 2017 at 2:33 AM, Steve Dickson <SteveD@redhat.com> wrote:
>
>
> On 04/09/2017 12:12 PM, ChunYu Wang wrote:
>> Signed-off-by: ChunYu Wang <chunwang@redhat.com>
>> ---
>> Fix a potential memory leak issue caused by unfree pathname 'path'.
>>
>> systemd/nfs-server-generator.c | 1 +
>> 1 file changed, 1 insertion(+)
>>
>> diff --git a/systemd/nfs-server-generator.c b/systemd/nfs-server-generator.c
>> index 4aa6509..441cec5 100644
>> --- a/systemd/nfs-server-generator.c
>> +++ b/systemd/nfs-server-generator.c
>> @@ -139,6 +139,7 @@ int main(int argc, char *argv[])
>> strcat(path, filebase);
>> f = fopen(path, "w");
>> if (!f)
>> + free(path);
>> exit(1);
> First of all you need some '{' '}' so the process will not
> always exit when f != NULL...
>
> Secondly dead process don't leak memory. :-) They don't leak anything... they are died! ;-)
>
> steved.
>
>> fprintf(f, "# Automatically generated by nfs-server-generator\n\n[Unit]\n");
>>
>>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2017-04-10 3:09 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-04-09 16:12 [PATCH] nfs-server-generator: fix a potential memory leak issue ChunYu Wang
2017-04-09 18:33 ` Steve Dickson
2017-04-10 3:09 ` ChunYu Wang
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.