summaryrefslogtreecommitdiff
path: root/source3
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2005-12-14 00:42:40 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 11:05:49 -0500
commit762901cfb9aabb717b8312d546ab20f8bacb1e29 (patch)
tree6f2667054ff7be5a0355eb8ae70010ab016e667d /source3
parent4d3152e1454ce62f3d1f864ccbf2a58234dab09d (diff)
downloadsamba-762901cfb9aabb717b8312d546ab20f8bacb1e29.tar.gz
samba-762901cfb9aabb717b8312d546ab20f8bacb1e29.tar.bz2
samba-762901cfb9aabb717b8312d546ab20f8bacb1e29.zip
r12221: Fix error code paths that can potentially leave a dangling lock.
Jeremy. (This used to be commit 123135ed1ddd84cc0a5e8e5ca06a0703d1944e37)
Diffstat (limited to 'source3')
-rw-r--r--source3/locking/locking.c15
1 files changed, 13 insertions, 2 deletions
diff --git a/source3/locking/locking.c b/source3/locking/locking.c
index d89fe931ef..b823b4712e 100644
--- a/source3/locking/locking.c
+++ b/source3/locking/locking.c
@@ -595,12 +595,18 @@ struct share_mode_lock *get_share_mode_lock(TALLOC_CTX *mem_ctx,
return NULL;
}
+ /* Ensure we set every field here as the destructor must be
+ valid even if parse_share_modes fails. */
+
+ lck->servicepath = NULL;
+ lck->filename = NULL;
lck->dev = dev;
lck->ino = ino;
- lck->delete_on_close = False;
lck->num_share_modes = 0;
lck->share_modes = NULL;
+ lck->delete_on_close = False;
lck->modified = False;
+ lck->fresh = False;
if (tdb_chainlock(tdb, key) != 0) {
DEBUG(3, ("Could not lock share entry\n"));
@@ -608,6 +614,12 @@ struct share_mode_lock *get_share_mode_lock(TALLOC_CTX *mem_ctx,
return NULL;
}
+ /* We must set the destructor immediately after the chainlock
+ ensure the lock is cleaned up on any of the error return
+ paths below. */
+
+ talloc_set_destructor(lck, share_mode_lock_destructor);
+
data = tdb_fetch(tdb, key);
lck->fresh = (data.dptr == NULL);
@@ -634,7 +646,6 @@ struct share_mode_lock *get_share_mode_lock(TALLOC_CTX *mem_ctx,
}
}
- talloc_set_destructor(lck, share_mode_lock_destructor);
SAFE_FREE(data.dptr);
return lck;