From 3a0c6e99de4377f44bc29766b6ceb79040caed9f Mon Sep 17 00:00:00 2001 From: Ralph Boehme Date: Wed, 8 Jan 2025 15:43:04 +0100 Subject: [PATCH] s3/brlock: don't increment current_lock_count if do_lock_fn() failed Also only assign psmblctx and pblocker_pid if the lock request failed. BUG: https://bugzilla.samba.org/show_bug.cgi?id=15767 Signed-off-by: Ralph Boehme Reviewed-by: Stefan Metzmacher --- source3/locking/locking.c | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/source3/locking/locking.c b/source3/locking/locking.c index 62f3e2e8037..1c5ebbcbcec 100644 --- a/source3/locking/locking.c +++ b/source3/locking/locking.c @@ -344,19 +344,21 @@ NTSTATUS do_lock(files_struct *fsp, nt_errstr(status)); return status; } - - if (psmblctx != NULL) { - *psmblctx = state.blocker_smblctx; - } - if (pblocker_pid != NULL) { - *pblocker_pid = state.blocker_pid; + if (!NT_STATUS_IS_OK(state.status)) { + DBG_DEBUG("do_lock_fn returned %s\n", + nt_errstr(state.status)); + if (psmblctx != NULL) { + *psmblctx = state.blocker_smblctx; + } + if (pblocker_pid != NULL) { + *pblocker_pid = state.blocker_pid; + } + return state.status; } - DBG_DEBUG("returning status=%s\n", nt_errstr(state.status)); - increment_current_lock_count(fsp, lock_flav); - return state.status; + return NT_STATUS_OK; } /**************************************************************************** -- 2.47.2