]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
s3:locking: make use of share_mode_lock_access_private_data() in reset_share_mode_entry()
authorStefan Metzmacher <metze@samba.org>
Fri, 26 Aug 2022 10:11:44 +0000 (12:11 +0200)
committerJeremy Allison <jra@samba.org>
Tue, 20 Sep 2022 00:34:35 +0000 (00:34 +0000)
We should avoid dereference 'struct share_mode_lock' as much as possible.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=15125

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
source3/locking/share_mode_lock.c

index f7adfc45bb7d700346ad896615355b0ddbfa0e6d..763961a5f53f2087b8133676751f46b048c58411 100644 (file)
@@ -2546,8 +2546,9 @@ bool reset_share_mode_entry(
        uint64_t new_mid,
        uint64_t new_share_file_id)
 {
-       struct share_mode_data *d = lck->data;
-       TDB_DATA key = locking_key(&d->id);
+       struct file_id id = share_mode_lock_file_id(lck);
+       struct share_mode_data *d = NULL;
+       TDB_DATA key = locking_key(&id);
        struct locking_tdb_data *ltdb = NULL;
        struct share_mode_entry e;
        struct share_mode_entry_buf e_buf;
@@ -2556,6 +2557,17 @@ bool reset_share_mode_entry(
        bool ret = false;
        bool ok;
 
+       status = share_mode_lock_access_private_data(lck, &d);
+       if (!NT_STATUS_IS_OK(status)) {
+               struct file_id_buf id_buf;
+               /* Any error recovery possible here ? */
+               DBG_ERR("share_mode_lock_access_private_data() failed for "
+                       "%s - %s\n",
+                       file_id_str_buf(id, &id_buf),
+                       nt_errstr(status));
+               return false;
+       }
+
        status = locking_tdb_data_fetch(key, talloc_tos(), &ltdb);
        if (!NT_STATUS_IS_OK(status)) {
                DBG_ERR("locking_tdb_data_fetch failed: %s\n",