Union FS: Fix a reference counting problem

This commit is contained in:
Gregory Nutt 2015-06-06 13:53:36 -06:00
parent a9b5145525
commit 6563d0e444

View File

@ -701,7 +701,7 @@ static int unionfs_open(FAR struct file *filep, FAR const char *relpath,
return ret; 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)); uf = (FAR struct unionfs_file_s *)kmm_malloc(sizeof(struct unionfs_file_s));
if (uf == NULL) if (uf == NULL)
@ -749,6 +749,13 @@ static int unionfs_open(FAR struct file *filep, FAR const char *relpath,
uf->uf_ndx = 1; 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; filep->f_priv = (FAR void *)uf;
ret = OK; ret = OK;