Commit a3ed9b81 by t00416110

conf.c: fix memory leak and mount error

1. cleanup namespace memory 2. fix bug when ro mount not setted, mount propagation will be skipped. Signed-off-by: 's avatart00416110 <tanyifeng1@huawei.com>
parent 20b4a592
...@@ -2103,6 +2103,9 @@ static int mount_entry(const char *fsname, const char *target, ...@@ -2103,6 +2103,9 @@ static int mount_entry(const char *fsname, const char *target,
} }
} }
#ifdef HAVE_STATVFS
skipremount:
#endif
if (pflags) { if (pflags) {
ret = mount(NULL, target, NULL, pflags, NULL); ret = mount(NULL, target, NULL, pflags, NULL);
if (ret < 0) { if (ret < 0) {
...@@ -2119,10 +2122,6 @@ static int mount_entry(const char *fsname, const char *target, ...@@ -2119,10 +2122,6 @@ static int mount_entry(const char *fsname, const char *target,
DEBUG("Changed mount propagation for \"%s\"", target); DEBUG("Changed mount propagation for \"%s\"", target);
} }
#ifdef HAVE_STATVFS
skipremount:
#endif
DEBUG("Mounted \"%s\" on \"%s\" with filesystem type \"%s\"", DEBUG("Mounted \"%s\" on \"%s\" with filesystem type \"%s\"",
srcpath ? srcpath : "(null)", target, fstype); srcpath ? srcpath : "(null)", target, fstype);
...@@ -3833,6 +3832,16 @@ int lxc_clear_config_keepcaps(struct lxc_conf *c) ...@@ -3833,6 +3832,16 @@ int lxc_clear_config_keepcaps(struct lxc_conf *c)
return 0; return 0;
} }
int lxc_clear_namespace(struct lxc_conf *c)
{
int i;
for (i = 0; i < LXC_NS_MAX; i++) {
free(c->ns_share[i]);
c->ns_share[i] = NULL;
}
return 0;
}
int lxc_clear_cgroups(struct lxc_conf *c, const char *key, int version) int lxc_clear_cgroups(struct lxc_conf *c, const char *key, int version)
{ {
char *global_token, *namespaced_token; char *global_token, *namespaced_token;
...@@ -4125,6 +4134,7 @@ void lxc_conf_free(struct lxc_conf *conf) ...@@ -4125,6 +4134,7 @@ void lxc_conf_free(struct lxc_conf *conf)
lxc_clear_sysctls(conf, "lxc.sysctl"); lxc_clear_sysctls(conf, "lxc.sysctl");
lxc_clear_procs(conf, "lxc.proc"); lxc_clear_procs(conf, "lxc.proc");
lxc_clear_apparmor_raw(conf); lxc_clear_apparmor_raw(conf);
lxc_clear_namespace(conf);
free(conf->cgroup_meta.dir); free(conf->cgroup_meta.dir);
free(conf->cgroup_meta.controllers); free(conf->cgroup_meta.controllers);
free(conf->shmount.path_host); free(conf->shmount.path_host);
......
...@@ -462,5 +462,6 @@ extern int lxc_clear_sysctls(struct lxc_conf *c, const char *key); ...@@ -462,5 +462,6 @@ extern int lxc_clear_sysctls(struct lxc_conf *c, const char *key);
extern int setup_proc_filesystem(struct lxc_list *procs, pid_t pid); extern int setup_proc_filesystem(struct lxc_list *procs, pid_t pid);
extern int lxc_clear_procs(struct lxc_conf *c, const char *key); extern int lxc_clear_procs(struct lxc_conf *c, const char *key);
extern int lxc_clear_apparmor_raw(struct lxc_conf *c); extern int lxc_clear_apparmor_raw(struct lxc_conf *c);
extern int lxc_clear_namespace(struct lxc_conf *c);
#endif /* __LXC_CONF_H */ #endif /* __LXC_CONF_H */
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