smbd: Clean up leases.tdb if set_share_mode() fails
authorVolker Lendecke <vl@samba.org>
Tue, 6 Aug 2019 08:45:27 +0000 (10:45 +0200)
committerJeremy Allison <jra@samba.org>
Tue, 6 Aug 2019 21:49:30 +0000 (21:49 +0000)
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
source3/smbd/open.c

index 01f62223ddb43bd6c634d7bd7dc9012453b1a155..d70ea8b5a5d6cfba5fdbc793f03c681b996dfba2 100644 (file)
@@ -2354,6 +2354,17 @@ static NTSTATUS grant_fsp_oplock_type(struct smb_request *req,
                share_access,
                access_mask);
        if (!ok) {
+               if (fsp->oplock_type == LEASE_OPLOCK) {
+                       status = remove_lease_if_stale(
+                               lck->data,
+                               fsp_client_guid(fsp),
+                               &fsp->lease->lease.lease_key);
+                       if (!NT_STATUS_IS_OK(status)) {
+                               DBG_WARNING("remove_lease_if_stale "
+                                           "failed: %s\n",
+                                           nt_errstr(status));
+                       }
+               }
                return NT_STATUS_NO_MEMORY;
        }