diff mbox series

maketable: clean up resources

Message ID 20221012093534.15433-1-gaoxingwang1@huawei.com (mailing list archive)
State Rejected
Delegated to: Stephen Hemminger
Headers show
Series maketable: clean up resources | expand

Checks

Context Check Description
netdev/tree_selection success Not a local patch

Commit Message

gaoxingwang Oct. 12, 2022, 9:35 a.m. UTC
Signed-off-by: gaoxingwang <gaoxingwang1@huawei.com>
---
 netem/maketable.c | 3 +++
 1 file changed, 3 insertions(+)

Comments

Stephen Hemminger Oct. 18, 2022, 3:29 a.m. UTC | #1
On Wed, 12 Oct 2022 17:35:34 +0800
gaoxingwang <gaoxingwang1@huawei.com> wrote:

> Signed-off-by: gaoxingwang <gaoxingwang1@huawei.com>
> ---
>  netem/maketable.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/netem/maketable.c b/netem/maketable.c
> index ccb8f0c6..f91ce221 100644
> --- a/netem/maketable.c
> +++ b/netem/maketable.c
> @@ -230,5 +230,8 @@ main(int argc, char **argv)
>  	inverse = inverttable(table, TABLESIZE, DISTTABLESIZE, total);
>  	interpolatetable(inverse, TABLESIZE);
>  	printtable(inverse, TABLESIZE);
> +	free(table);
> +	free(inverse)
> +	close(fp);
>  	return 0;
>  }

Why bother. This is a tool only used during builds and this the end
of the main program so all resources will disappear after return.
gaoxingwang Oct. 20, 2022, 9:36 a.m. UTC | #2
On Mon, 17 Oct 2022 20:29:14 -0700	[thread overview]

>On Wed, 12 Oct 2022 17:35:34 +0800
>gaoxingwang <gaoxingwang1@huawei.com> wrote:
>
>> Signed-off-by: gaoxingwang <gaoxingwang1@huawei.com>
>> ---
>>  netem/maketable.c | 3 +++
>>  1 file changed, 3 insertions(+)
>> 
>> diff --git a/netem/maketable.c b/netem/maketable.c
>> index ccb8f0c6..f91ce221 100644
>> --- a/netem/maketable.c
>> +++ b/netem/maketable.c
>> @@ -230,5 +230,8 @@ main(int argc, char **argv)
>>  	inverse = inverttable(table, TABLESIZE, DISTTABLESIZE, total);
>>  	interpolatetable(inverse, TABLESIZE);
>>  	printtable(inverse, TABLESIZE);
>> +	free(table);
>> +	free(inverse)
>> +	close(fp);
>>  	return 0;
>>  }
>
>Why bother. This is a tool only used during builds and this the end
>of the main program so all resources will disappear after return.

I found this issue because a white box scan of the code. Maybe fixing this will save us from the effort to explain it.
diff mbox series

Patch

diff --git a/netem/maketable.c b/netem/maketable.c
index ccb8f0c6..f91ce221 100644
--- a/netem/maketable.c
+++ b/netem/maketable.c
@@ -230,5 +230,8 @@  main(int argc, char **argv)
 	inverse = inverttable(table, TABLESIZE, DISTTABLESIZE, total);
 	interpolatetable(inverse, TABLESIZE);
 	printtable(inverse, TABLESIZE);
+	free(table);
+	free(inverse)
+	close(fp);
 	return 0;
 }