From 06e2aa3cba7af00bd8f9ee92496cd6e4e94f14a1 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Fri, 26 Aug 2022 12:11:44 +0200 Subject: [PATCH] s3:locking: make use of share_mode_lock_access_private_data() in reset_share_mode_entry() 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 Reviewed-by: Jeremy Allison --- source3/locking/share_mode_lock.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/source3/locking/share_mode_lock.c b/source3/locking/share_mode_lock.c index f7adfc45bb7..763961a5f53 100644 --- a/source3/locking/share_mode_lock.c +++ b/source3/locking/share_mode_lock.c @@ -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(), <db); if (!NT_STATUS_IS_OK(status)) { DBG_ERR("locking_tdb_data_fetch failed: %s\n", -- 2.34.1