Commit 469b6a66 by Vitaly Lavrov Committed by Stéphane Graber

fix realloc() error on reboot container

The container with "lxc.network.type=phys" halted with error on reboot. Error message: *** glibc detected *** lxc-start: realloc(): invalid pointer: 0x0948eed0 *** We have a sequence: 1) conf->saved_nic = relloc(NULL) on start start.c:container save_phys_nics() 2) free(conf->saved_nics) after stop container conf.c:lxc_rename_phys_nics_on_shutdown() 3) conf->saved_nic = relloc(conf->saved_nics) on restart container start.c:save_phys_nics() -> error relloc() free(conf->saved_nics) in lxc_rename_phys_nics_on_shutdown() unnecessary, it will be called later in lxc_clear_saved_nics(). Signed-off-by: 's avatarVitaly Lavrov <vel21ripn@gmail.com> Acked-by: 's avatarStéphane Graber <stgraber@ubuntu.com>
parent 3efa3bad
...@@ -2565,7 +2565,6 @@ void lxc_rename_phys_nics_on_shutdown(struct lxc_conf *conf) ...@@ -2565,7 +2565,6 @@ void lxc_rename_phys_nics_on_shutdown(struct lxc_conf *conf)
free(s->orig_name); free(s->orig_name);
} }
conf->num_savednics = 0; conf->num_savednics = 0;
free(conf->saved_nics);
} }
static char *default_rootfs_mount = LXCROOTFSMOUNT; static char *default_rootfs_mount = LXCROOTFSMOUNT;
...@@ -4075,11 +4074,10 @@ static void lxc_clear_saved_nics(struct lxc_conf *conf) ...@@ -4075,11 +4074,10 @@ static void lxc_clear_saved_nics(struct lxc_conf *conf)
{ {
int i; int i;
if (!conf->num_savednics) if (!conf->saved_nics)
return; return;
for (i=0; i < conf->num_savednics; i++) for (i=0; i < conf->num_savednics; i++)
free(conf->saved_nics[i].orig_name); free(conf->saved_nics[i].orig_name);
conf->saved_nics = 0;
free(conf->saved_nics); free(conf->saved_nics);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment