intel/tools: fix resource leak

Submitted by andrey simiklit on Oct. 26, 2018, 2:11 p.m.

Details

Message ID 20181026141135.20934-1-asimiklit.work@gmail.com
State New
Headers show
Series "intel/tools: fix resource leak" ( rev: 1 ) in Mesa

Not browsing as part of any series.

Commit Message

andrey simiklit Oct. 26, 2018, 2:11 p.m.
From: Andrii Simiklit <andrii.simiklit@globallogic.com>

Some memory and file descriptors are not freed/closed.

Signed-off-by: Andrii Simiklit <andrii.simiklit@globallogic.com>
---
 src/intel/tools/error2aub.c | 6 ++++++
 1 file changed, 6 insertions(+)

Patch hide | download patch | download mbox

diff --git a/src/intel/tools/error2aub.c b/src/intel/tools/error2aub.c
index 8a23d5ef1e..451fd8c74a 100644
--- a/src/intel/tools/error2aub.c
+++ b/src/intel/tools/error2aub.c
@@ -326,6 +326,12 @@  main(int argc, char *argv[])
 
    aub_write_exec(&aub, batch_addr, aub_gtt_size(&aub), I915_EXEC_RENDER);
 
+   free(out_filename);
+   free(line);
+   if(err_file) {
+      fclose(err_file);
+   }
+   aub_file_finish(&aub);
    return EXIT_SUCCESS;
 }
 

Comments

On 26/10/2018 15:11, asimiklit.work@gmail.com wrote:
> From: Andrii Simiklit <andrii.simiklit@globallogic.com>
>
> Some memory and file descriptors are not freed/closed.


Thanks a lot :


Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>


>
> Signed-off-by: Andrii Simiklit <andrii.simiklit@globallogic.com>
> ---
>   src/intel/tools/error2aub.c | 6 ++++++
>   1 file changed, 6 insertions(+)
>
> diff --git a/src/intel/tools/error2aub.c b/src/intel/tools/error2aub.c
> index 8a23d5ef1e..451fd8c74a 100644
> --- a/src/intel/tools/error2aub.c
> +++ b/src/intel/tools/error2aub.c
> @@ -326,6 +326,12 @@ main(int argc, char *argv[])
>   
>      aub_write_exec(&aub, batch_addr, aub_gtt_size(&aub), I915_EXEC_RENDER);
>   
> +   free(out_filename);
> +   free(line);
> +   if(err_file) {
> +      fclose(err_file);
> +   }
> +   aub_file_finish(&aub);
>      return EXIT_SUCCESS;
>   }
>
Hello,

Thanks a lot for reviewing and for quick reply.
Sorry, I forgot ( I thought that it impossible to have the feedback in a 10
minutes on Friday :-) ) to update my inbox and sent version v2,
I guess that I fix small issue in v2:
-   aub_file_finish(&aub);
+   if(aub.file) {
+      aub_file_finish(&aub);
+   } else if(aub_file) {
+      fclose(aub_file);
+   }

Thanks,
Andrii.

On Fri, Oct 26, 2018 at 5:20 PM Lionel Landwerlin <
lionel.g.landwerlin@intel.com> wrote:

> On 26/10/2018 15:11, asimiklit.work@gmail.com wrote:
> > From: Andrii Simiklit <andrii.simiklit@globallogic.com>
> >
> > Some memory and file descriptors are not freed/closed.
>
>
> Thanks a lot :
>
>
> Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
>
>
> >
> > Signed-off-by: Andrii Simiklit <andrii.simiklit@globallogic.com>
> > ---
> >   src/intel/tools/error2aub.c | 6 ++++++
> >   1 file changed, 6 insertions(+)
> >
> > diff --git a/src/intel/tools/error2aub.c b/src/intel/tools/error2aub.c
> > index 8a23d5ef1e..451fd8c74a 100644
> > --- a/src/intel/tools/error2aub.c
> > +++ b/src/intel/tools/error2aub.c
> > @@ -326,6 +326,12 @@ main(int argc, char *argv[])
> >
> >      aub_write_exec(&aub, batch_addr, aub_gtt_size(&aub),
> I915_EXEC_RENDER);
> >
> > +   free(out_filename);
> > +   free(line);
> > +   if(err_file) {
> > +      fclose(err_file);
> > +   }
> > +   aub_file_finish(&aub);
> >      return EXIT_SUCCESS;
> >   }
> >
>
>
>