Re: [PATCH 2/3] virnetsocket: Resolve Coverity RESOURCE_LEAK

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

 



On 08/22/2014 05:28 PM, John Ferlan wrote:
> Since '1b807f92d' - Coverity complains that in the error paths of
> both virFork() and virProcessWait() that the 'passfd' will not be closed
> 
> Signed-off-by: John Ferlan <jferlan@xxxxxxxxxx>
> ---
>  src/rpc/virnetsocket.c | 8 ++++++--
>  1 file changed, 6 insertions(+), 2 deletions(-)
> 
> diff --git a/src/rpc/virnetsocket.c b/src/rpc/virnetsocket.c
> index f913365..ce908fa 100644
> --- a/src/rpc/virnetsocket.c
> +++ b/src/rpc/virnetsocket.c
> @@ -593,8 +593,10 @@ int virNetSocketNewConnectUNIX(const char *path,
>           * behaviour on sockets according to POSIX, so it doesn't
>           * work outside Linux.
>           */
> -        if ((pid = virFork()) < 0)
> +        if ((pid = virFork()) < 0) {
> +            VIR_FORCE_CLOSE(passfd);
>              goto error;
> +        }
>  
>          if (pid == 0) {
>              umask(0077);
> @@ -604,8 +606,10 @@ int virNetSocketNewConnectUNIX(const char *path,
>              _exit(EXIT_SUCCESS);
>          }
>  
> -        if (virProcessWait(pid, &status, false) < 0)
> +        if (virProcessWait(pid, &status, false) < 0) {
> +            VIR_FORCE_CLOSE(passfd);
>              goto error;
> +        }
>  
>          if (status != EXIT_SUCCESS) {
>              /*
> 

Unless I'm missing something, passfd will be leaked on all error paths unless
virNetSocketForkDaemon succeeds.

Jan

Attachment: signature.asc
Description: OpenPGP digital signature

--
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]