[CRIU] [PATCH] cr-dump: allocate dfds near the place where it's used
Pavel Emelyanov
xemul at parallels.com
Tue Apr 8 04:26:32 PDT 2014
On 04/07/2014 11:32 PM, Andrey Vagin wrote:
What for?
> Signed-off-by: Andrey Vagin <avagin at openvz.org>
> ---
> cr-dump.c | 11 +++++------
> 1 file changed, 5 insertions(+), 6 deletions(-)
>
> diff --git a/cr-dump.c b/cr-dump.c
> index 464963d..d326cbf 100644
> --- a/cr-dump.c
> +++ b/cr-dump.c
> @@ -1381,7 +1381,7 @@ static int dump_one_task(struct pstree_item *item)
> int ret = -1;
> struct parasite_dump_misc misc;
> struct cr_fdset *cr_fdset = NULL;
> - struct parasite_drain_fd *dfds;
> + struct parasite_drain_fd *dfds = NULL;
> struct proc_posix_timers_stat proc_args;
> struct proc_status_creds cr;
>
> @@ -1398,10 +1398,6 @@ static int dump_one_task(struct pstree_item *item)
> */
> return 0;
>
> - dfds = xmalloc(sizeof(*dfds));
> - if (!dfds)
> - goto err_free;
> -
> pr_info("Obtaining task stat ... ");
> ret = parse_pid_stat(pid, &pps_buf);
> if (ret < 0)
> @@ -1423,6 +1419,10 @@ static int dump_one_task(struct pstree_item *item)
> goto err;
> }
>
> + dfds = xmalloc(sizeof(*dfds));
> + if (!dfds)
> + goto err;
> +
> ret = collect_fds(pid, dfds);
> if (ret) {
> pr_err("Collect fds (pid: %d) failed with %d\n", pid, ret);
> @@ -1578,7 +1578,6 @@ static int dump_one_task(struct pstree_item *item)
> close_cr_fdset(&cr_fdset);
> err:
> close_pid_proc();
> -err_free:
> free_mappings(&vmas);
> xfree(dfds);
> return ret;
>
More information about the CRIU
mailing list