Re: [PATCH v2] nwfilter: Don't leak @inetaddr

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




On 09/26/2017 03:54 PM, ZhiPeng Lu wrote:
> In learnIPAddressThread()the @inetaddr may be leaked.
> 
> Signed-off-by: ZhiPeng Lu <lu.zhipeng@xxxxxxxxxx>
> ---
>  src/nwfilter/nwfilter_learnipaddr.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/src/nwfilter/nwfilter_learnipaddr.c b/src/nwfilter/nwfilter_learnipaddr.c
> index cfd92d9..5dc212e 100644
> --- a/src/nwfilter/nwfilter_learnipaddr.c
> +++ b/src/nwfilter/nwfilter_learnipaddr.c
> @@ -625,6 +625,7 @@ learnIPAddressThread(void *arg)
>              if (virNWFilterIPAddrMapAddIPAddr(req->ifname, inetaddr) < 0) {
>                  VIR_ERROR(_("Failed to add IP address %s to IP address "
>                            "cache for interface %s"), inetaddr, req->ifname);
> +                VIR_FREE(inetaddr);
>              }
>  
>              ret = virNWFilterInstantiateFilterLate(req->driver,
> @@ -636,7 +637,8 @@ learnIPAddressThread(void *arg)
>                                                     req->filtername,
>                                                     req->filterparams);
>              VIR_DEBUG("Result from applying firewall rules on "
> -                      "%s with IP addr %s : %d", req->ifname, inetaddr, ret);
> +                      "%s with IP addr %s : %d", req->ifname, NULLSTR(inetaddr), ret);> +

Still not quite right... VIR_FREE() only happens if
virNWFilterIPAddrMapAddIPAddr() < 0.

Not sure what the purpose of a VIR_FREE in the upper condition and then
NULLSTR() below would be...  We're still calling
virNWFilterInstantiateFilterLate regardless and still want the VIR_DEBUG
printed.

Perhaps just a VIR_FREE() after the VIR_DEBUG would seem to be
sufficient since there's no escape clause.  The VIR_ERROR may help us
understand why/if ret != 0 though... I didn't put much thought into that
though.

John

>          }
>      } else {
>          if (showError)
> 

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]
  Powered by Linux