2
0
mirror of https://github.com/checkpoint-restore/criu synced 2025-08-31 14:25:49 +00:00

zdtm: add MNTNS_ZDTM macro to fix initialization

With this macro we can easily declare struct mntns_zdtm variables with
all lists properly initiallized. Let's use it in mount_complex_sharing
as without it we can have segfault on error path when accessing
uninitialized list pointers.

Signed-off-by: Pavel Tikhomirov <ptikhomirov@virtuozzo.com>
This commit is contained in:
Pavel Tikhomirov
2023-03-20 11:33:37 +08:00
committed by Andrei Vagin
parent 12423abdb5
commit a0158e6927
2 changed files with 10 additions and 1 deletions

View File

@@ -24,6 +24,14 @@ struct mntns_zdtm {
struct list_head sharing_groups_list;
};
#define MNTNS_ZDTM_INIT(name) \
{ \
.mountinfo_list = LIST_HEAD_INIT(name.mountinfo_list), \
.topology_list = LIST_HEAD_INIT(name.topology_list), \
.sharing_groups_list = LIST_HEAD_INIT(name.sharing_groups_list), \
}
#define MNTNS_ZDTM(name) struct mntns_zdtm name = MNTNS_ZDTM_INIT(name)
struct sharing_group {
int shared_id;
int master_id;

View File

@@ -212,7 +212,8 @@ static int mount_loop(void)
int main(int argc, char **argv)
{
struct mntns_zdtm mntns_before, mntns_after;
MNTNS_ZDTM(mntns_before);
MNTNS_ZDTM(mntns_after);
int ret = 1;
test_init(argc, argv);