qemu-devel
[Top][All Lists]
Advanced

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

Re: [PATCH] virtfs-proxy-helper: Fix a resource leak in main()


From: Greg Kurz
Subject: Re: [PATCH] virtfs-proxy-helper: Fix a resource leak in main()
Date: Thu, 26 Nov 2020 13:07:34 +0100

On Thu, 26 Nov 2020 10:16:24 +0000
Alex Chen <alex.chen@huawei.com> wrote:

> Only one of the options -s and -f can be used. When -f is used,
> the fd is created externally and does not need to be closed.

The process running virtfs-proxy-helper has its own copy of
the fd inherited from its parent. And this fd will be closed
eventually when the process terminates.

> When -s is used, a new socket fd is created, and this socket fd
> needs to be closed at the end of main().
> 

Same here, the new socket fd is closed when the process
terminates.

The only justification to merge such a change would be if
the code was sitting in some other function, in which
case we should indeed do proper rollback. But it is main()
here, so this patch isn't needed.

> Reported-by: Euler Robot <euler.robot@huawei.com>

Can you provide a copy of the report in case I'm
missing something ?

> Signed-off-by: Alex Chen <alex.chen@huawei.com>
> ---
>  fsdev/virtfs-proxy-helper.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/fsdev/virtfs-proxy-helper.c b/fsdev/virtfs-proxy-helper.c
> index 15c0e79b06..339d477169 100644
> --- a/fsdev/virtfs-proxy-helper.c
> +++ b/fsdev/virtfs-proxy-helper.c
> @@ -1154,6 +1154,9 @@ int main(int argc, char **argv)
>      process_requests(sock);
>  error:
>      g_free(rpath);
> +    if (sock_name) {
> +        close(sock);
> +    }
>      g_free(sock_name);
>      do_log(LOG_INFO, "Done\n");
>      closelog();




reply via email to

[Prev in Thread] Current Thread [Next in Thread]