From 6563d0e44483392db06eefcc31d0ebcbdbbcac2b Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Sat, 6 Jun 2015 13:53:36 -0600 Subject: [PATCH] Union FS: Fix a reference counting problem --- fs/unionfs/fs_unionfs.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/fs/unionfs/fs_unionfs.c b/fs/unionfs/fs_unionfs.c index e708941327a..ea33eef6341 100644 --- a/fs/unionfs/fs_unionfs.c +++ b/fs/unionfs/fs_unionfs.c @@ -701,7 +701,7 @@ static int unionfs_open(FAR struct file *filep, FAR const char *relpath, return ret; } - /* Alloate a container to hold the open file system information */ + /* Allocate a container to hold the open file system information */ uf = (FAR struct unionfs_file_s *)kmm_malloc(sizeof(struct unionfs_file_s)); if (uf == NULL) @@ -749,6 +749,13 @@ static int unionfs_open(FAR struct file *filep, FAR const char *relpath, uf->uf_ndx = 1; } + /* Increment the open reference count */ + + ui->ui_nopen++; + DEBUGASSERT(ui->ui_nopen > 0); + + /* Save our private data in the file structure */ + filep->f_priv = (FAR void *)uf; ret = OK;