[PATCH 0/9] Some Coverity memory leak patches

John Ferlan posted 9 patches 4 years, 5 months ago
Test syntax-check failed
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/libvirt tags/patchew/20200616120710.2628344-1-jferlan@redhat.com
src/conf/cpu_conf.c        | 2 +-
src/lxc/lxc_controller.c   | 3 ++-
src/openvz/openvz_conf.c   | 7 ++-----
src/remote/remote_driver.c | 2 +-
src/test/test_driver.c     | 2 +-
src/util/iohelper.c        | 7 +++++++
src/util/virauth.c         | 5 +----
src/util/virauthconfig.c   | 4 ++--
src/util/virauthconfig.h   | 2 +-
src/util/virpci.c          | 1 +
tests/virauthconfigtest.c  | 2 +-
11 files changed, 20 insertions(+), 17 deletions(-)
[PATCH 0/9] Some Coverity memory leak patches
Posted by John Ferlan 4 years, 5 months ago
Even though I changed roles, the cron job still runs.  I recently
updated to a newer coverity version and it found some new stuff and
even more false positives. It's still very unhappy with the usage
of GLIB_DEPRECATED_ENUMERATOR_IN_* macros for *glib/gspawn.h and
*gobject/gparam.h, but I can work around that. I had to disable
the use_after_free type checking because the virObject to GObject
change just caused a large number of possible false positives for
virObjectUnref usages (coverity cannot keep track of all the counts).

Anyway, I had a few spare cycles, so I figured I'd pass along at
least the memory leak and usage things that were found. I haven't
posted in a while so hopefully I haven't missed some subtlety.

FWIW: I no longer have commit access so I'm at the mercy of someone
      else pushing my patches now.


John Ferlan (9):
  util: Fix memory leak in virAuthGetCredential
  util: Fix memory leak in virAuthConfigLookup
  lxc: Fix memory leak in virLXCControllerPopulateDevices
  util: Fix memory leak in virPCIProbeStubDriver
  test: Fix memory leak in testParseXMLDocFromFile
  conf: Fix memory leak in openvzWriteConfigParam
  conf: Fix memory leak in openvzReadFSConf
  conf: Fix memory leak in virCPUDefParseXML
  util: Avoid using wrong free function

 src/conf/cpu_conf.c        | 2 +-
 src/lxc/lxc_controller.c   | 3 ++-
 src/openvz/openvz_conf.c   | 7 ++-----
 src/remote/remote_driver.c | 2 +-
 src/test/test_driver.c     | 2 +-
 src/util/iohelper.c        | 7 +++++++
 src/util/virauth.c         | 5 +----
 src/util/virauthconfig.c   | 4 ++--
 src/util/virauthconfig.h   | 2 +-
 src/util/virpci.c          | 1 +
 tests/virauthconfigtest.c  | 2 +-
 11 files changed, 20 insertions(+), 17 deletions(-)

-- 
2.25.4

Re: [PATCH 0/9] Some Coverity memory leak patches
Posted by Peter Krempa 4 years, 5 months ago
On Tue, Jun 16, 2020 at 08:07:01 -0400, John Ferlan wrote:
> Even though I changed roles, the cron job still runs.  I recently
> updated to a newer coverity version and it found some new stuff and
> even more false positives. It's still very unhappy with the usage
> of GLIB_DEPRECATED_ENUMERATOR_IN_* macros for *glib/gspawn.h and
> *gobject/gparam.h, but I can work around that. I had to disable
> the use_after_free type checking because the virObject to GObject
> change just caused a large number of possible false positives for
> virObjectUnref usages (coverity cannot keep track of all the counts).
> 
> Anyway, I had a few spare cycles, so I figured I'd pass along at
> least the memory leak and usage things that were found. I haven't
> posted in a while so hopefully I haven't missed some subtlety.
> 
> FWIW: I no longer have commit access so I'm at the mercy of someone
>       else pushing my patches now.
> 
> 
> John Ferlan (9):
>   util: Fix memory leak in virAuthGetCredential
>   util: Fix memory leak in virAuthConfigLookup
>   lxc: Fix memory leak in virLXCControllerPopulateDevices
>   util: Fix memory leak in virPCIProbeStubDriver
>   test: Fix memory leak in testParseXMLDocFromFile
>   conf: Fix memory leak in openvzWriteConfigParam
>   conf: Fix memory leak in openvzReadFSConf
>   conf: Fix memory leak in virCPUDefParseXML

Patches 1-8:

Reviewed-by: Peter Krempa <pkrempa@redhat.com>

And I'll push them shortly with the fix mentioned in one of them.

>   util: Avoid using wrong free function
> 
>  src/conf/cpu_conf.c        | 2 +-
>  src/lxc/lxc_controller.c   | 3 ++-
>  src/openvz/openvz_conf.c   | 7 ++-----
>  src/remote/remote_driver.c | 2 +-
>  src/test/test_driver.c     | 2 +-
>  src/util/iohelper.c        | 7 +++++++
>  src/util/virauth.c         | 5 +----
>  src/util/virauthconfig.c   | 4 ++--
>  src/util/virauthconfig.h   | 2 +-
>  src/util/virpci.c          | 1 +
>  tests/virauthconfigtest.c  | 2 +-
>  11 files changed, 20 insertions(+), 17 deletions(-)
> 
> -- 
> 2.25.4
> 

Re: [PATCH 0/9] Some Coverity memory leak patches
Posted by John Ferlan 4 years, 5 months ago

On 6/16/20 8:25 AM, Peter Krempa wrote:
> On Tue, Jun 16, 2020 at 08:07:01 -0400, John Ferlan wrote:
>> Even though I changed roles, the cron job still runs.  I recently
>> updated to a newer coverity version and it found some new stuff and
>> even more false positives. It's still very unhappy with the usage
>> of GLIB_DEPRECATED_ENUMERATOR_IN_* macros for *glib/gspawn.h and
>> *gobject/gparam.h, but I can work around that. I had to disable
>> the use_after_free type checking because the virObject to GObject
>> change just caused a large number of possible false positives for
>> virObjectUnref usages (coverity cannot keep track of all the counts).
>>
>> Anyway, I had a few spare cycles, so I figured I'd pass along at
>> least the memory leak and usage things that were found. I haven't
>> posted in a while so hopefully I haven't missed some subtlety.
>>
>> FWIW: I no longer have commit access so I'm at the mercy of someone
>>       else pushing my patches now.
>>
>>
>> John Ferlan (9):
>>   util: Fix memory leak in virAuthGetCredential
>>   util: Fix memory leak in virAuthConfigLookup
>>   lxc: Fix memory leak in virLXCControllerPopulateDevices
>>   util: Fix memory leak in virPCIProbeStubDriver
>>   test: Fix memory leak in testParseXMLDocFromFile
>>   conf: Fix memory leak in openvzWriteConfigParam
>>   conf: Fix memory leak in openvzReadFSConf
>>   conf: Fix memory leak in virCPUDefParseXML
> 
> Patches 1-8:
> 
> Reviewed-by: Peter Krempa <pkrempa@redhat.com>
> 
> And I'll push them shortly with the fix mentioned in one of them.
> 

OK - thanks!

John

I see why I commented the way I did for @absFile <sigh>, but yeah it's a
problem either way... Probably was more focused on the fact it was my
original blunder...

>>   util: Avoid using wrong free function
>>
>>  src/conf/cpu_conf.c        | 2 +-
>>  src/lxc/lxc_controller.c   | 3 ++-
>>  src/openvz/openvz_conf.c   | 7 ++-----
>>  src/remote/remote_driver.c | 2 +-
>>  src/test/test_driver.c     | 2 +-
>>  src/util/iohelper.c        | 7 +++++++
>>  src/util/virauth.c         | 5 +----
>>  src/util/virauthconfig.c   | 4 ++--
>>  src/util/virauthconfig.h   | 2 +-
>>  src/util/virpci.c          | 1 +
>>  tests/virauthconfigtest.c  | 2 +-
>>  11 files changed, 20 insertions(+), 17 deletions(-)
>>
>> -- 
>> 2.25.4
>>