pvfs_open: fix crash/leak in case pvfs_setup_oplock() fails
authorStefan Metzmacher <metze@samba.org>
Thu, 6 Mar 2008 14:34:37 +0000 (15:34 +0100)
committerStefan Metzmacher <metze@samba.org>
Thu, 6 Mar 2008 15:31:26 +0000 (16:31 +0100)
metze
(This used to be commit 5563238782e825f64a22b5f9e0a7deb687f50b19)

source4/ntvfs/posix/pvfs_open.c

index adf4c1ac185080f4a8f7a7d629aeea9dd6e29de9..792e35cd140e27866d4a6fa4ebcab135bfe8a083 100644 (file)
@@ -696,21 +696,20 @@ static NTSTATUS pvfs_create_file(struct pvfs_state *pvfs,
 
        DLIST_ADD(pvfs->files.list, f);
 
+       /* setup a destructor to avoid file descriptor leaks on
+          abnormal termination */
+       talloc_set_destructor(f, pvfs_fnum_destructor);
+       talloc_set_destructor(f->handle, pvfs_handle_destructor);
+
        if (pvfs->flags & PVFS_FLAG_FAKE_OPLOCKS) {
                oplock_granted = OPLOCK_BATCH;
        } else if (oplock_granted != OPLOCK_NONE) {
                status = pvfs_setup_oplock(f, oplock_granted);
                if (!NT_STATUS_IS_OK(status)) {
-                       talloc_free(lck);
                        return status;
                }
        }
 
-       /* setup a destructor to avoid file descriptor leaks on
-          abnormal termination */
-       talloc_set_destructor(f, pvfs_fnum_destructor);
-       talloc_set_destructor(f->handle, pvfs_handle_destructor);
-
        io->generic.out.oplock_level  = oplock_granted;
        io->generic.out.file.ntvfs    = f->ntvfs;
        io->generic.out.create_action = NTCREATEX_ACTION_CREATED;