[lxc-devel] [PATCH] lxc_monitor: fix memory leak. free @fds on ret 1

Serge Hallyn serge.hallyn at ubuntu.com
Fri Jun 5 14:00:11 UTC 2015


Hi,

so long as you are doing this, you could also call a helper
to close the opened fds?  And do so before the final return 0?

Quoting Arjun Sreedharan (arjun024 at gmail.com):
> Signed-off-by: Arjun Sreedharan <arjun024 at gmail.com>
> ---
>  src/lxc/lxc_monitor.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/src/lxc/lxc_monitor.c b/src/lxc/lxc_monitor.c
> index b3d8912..39764b8 100644
> --- a/src/lxc/lxc_monitor.c
> +++ b/src/lxc/lxc_monitor.c
> @@ -148,6 +148,7 @@ int main(int argc, char *argv[])
>  		fd = lxc_monitor_open(my_args.lxcpath[i]);
>  		if (fd < 0) {
>  			regfree(&preg);
> +			free(fds);
>  			return 1;
>  		}
>  		fds[i].fd = fd;
> @@ -160,6 +161,7 @@ int main(int argc, char *argv[])
>  	for (;;) {
>  		if (lxc_monitor_read_fdset(fds, nfds, &msg, -1) < 0) {
>  			regfree(&preg);
> +			free(fds);
>  			return 1;
>  		}
>  
> -- 
> 1.7.11.7
> 
> _______________________________________________
> lxc-devel mailing list
> lxc-devel at lists.linuxcontainers.org
> http://lists.linuxcontainers.org/listinfo/lxc-devel


More information about the lxc-devel mailing list