summaryrefslogtreecommitdiff
path: root/libnetfs/make-peropen.c
diff options
context:
space:
mode:
Diffstat (limited to 'libnetfs/make-peropen.c')
-rw-r--r--libnetfs/make-peropen.c21
1 files changed, 13 insertions, 8 deletions
diff --git a/libnetfs/make-peropen.c b/libnetfs/make-peropen.c
index 733bfdcb..7f2df053 100644
--- a/libnetfs/make-peropen.c
+++ b/libnetfs/make-peropen.c
@@ -25,7 +25,10 @@ struct peropen *
netfs_make_peropen (struct node *np, int flags, struct peropen *context)
{
struct peropen *po = malloc (sizeof (struct peropen));
-
+
+ if (!po)
+ return NULL;
+
po->filepointer = 0;
po->lock_status = LOCK_UN;
po->refcnt = 0;
@@ -35,6 +38,15 @@ netfs_make_peropen (struct node *np, int flags, struct peropen *context)
if (context)
{
+ if (context->path)
+ {
+ po->path = strdup (context->path);
+ if (! po->path) {
+ free(po);
+ return NULL;
+ }
+ }
+
po->root_parent = context->root_parent;
if (po->root_parent != MACH_PORT_NULL)
mach_port_mod_refs (mach_task_self (), po->root_parent,
@@ -48,13 +60,6 @@ netfs_make_peropen (struct node *np, int flags, struct peropen *context)
if (po->shadow_root_parent != MACH_PORT_NULL)
mach_port_mod_refs (mach_task_self (), po->shadow_root_parent,
MACH_PORT_RIGHT_SEND, 1);
-
- if (context->path)
- {
- po->path = strdup (context->path);
- if (! po->path)
- return ENOMEM;
- }
}
netfs_nref (np);