]> git.proxmox.com Git - mirror_lxcfs.git/commitdiff
fuse file info release: guard against multiple calls
authorSerge Hallyn <serge.hallyn@ubuntu.com>
Tue, 29 Mar 2016 18:35:01 +0000 (13:35 -0500)
committerSerge Hallyn <serge.hallyn@ubuntu.com>
Tue, 29 Mar 2016 18:42:47 +0000 (13:42 -0500)
While fuse clearly calls the release info helpers under pthread
lock, it's not as clear that it may not be called more than once.
Null everything after we free it.

The hope is that this will fix the occasional mysterious crashes
on very heavily used (50 containers nonstop) servers.

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
bindings.c

index a62215759dd0a842db56c650327a4e854e40ff6b..4e0cbfca7dbe483b8aefee6f7a554c7952feef32 100644 (file)
@@ -1682,22 +1682,29 @@ out:
        return ret;
 }
 
-static void do_release_file_info(struct file_info *f)
+static void do_release_file_info(struct fuse_file_info *fi)
 {
+       struct file_info *f = (struct file_info *)fi->fh;
+
        if (!f)
                return;
+
+       fi->fh = 0;
+
        free(f->controller);
+       f->controller = NULL;
        free(f->cgroup);
+       f->cgroup = NULL;
        free(f->file);
+       f->file = NULL;
        free(f->buf);
+       f->buf = NULL;
        free(f);
 }
 
 int cg_releasedir(const char *path, struct fuse_file_info *fi)
 {
-       struct file_info *d = (struct file_info *)fi->fh;
-
-       do_release_file_info(d);
+       do_release_file_info(fi);
        return 0;
 }
 
@@ -1824,9 +1831,7 @@ out:
 
 int cg_release(const char *path, struct fuse_file_info *fi)
 {
-       struct file_info *f = (struct file_info *)fi->fh;
-
-       do_release_file_info(f);
+       do_release_file_info(fi);
        return 0;
 }
 
@@ -3821,9 +3826,7 @@ int proc_access(const char *path, int mask)
 
 int proc_release(const char *path, struct fuse_file_info *fi)
 {
-       struct file_info *f = (struct file_info *)fi->fh;
-
-       do_release_file_info(f);
+       do_release_file_info(fi);
        return 0;
 }