mirror of
https://github.com/samba-team/samba.git
synced 2025-08-28 09:49:30 +03:00
s3/locking: Avoid a talloc for nonexisting fetch_share_mode_unlocked
Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Ralph Boehme <slow@samba.org>
This commit is contained in:
committed by
Ralph Boehme
parent
27daed8fcf
commit
66cba9939b
@ -623,19 +623,28 @@ fail:
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct fetch_share_mode_unlocked_state {
|
||||||
|
TALLOC_CTX *mem_ctx;
|
||||||
|
struct share_mode_lock *lck;
|
||||||
|
};
|
||||||
|
|
||||||
static void fetch_share_mode_unlocked_parser(
|
static void fetch_share_mode_unlocked_parser(
|
||||||
TDB_DATA key, TDB_DATA data, void *private_data)
|
TDB_DATA key, TDB_DATA data, void *private_data)
|
||||||
{
|
{
|
||||||
struct share_mode_lock *lck = talloc_get_type_abort(
|
struct fetch_share_mode_unlocked_state *state = private_data;
|
||||||
private_data, struct share_mode_lock);
|
|
||||||
|
|
||||||
if (data.dsize == 0) {
|
if (data.dsize == 0) {
|
||||||
/* Likely a ctdb tombstone record, ignore it */
|
/* Likely a ctdb tombstone record, ignore it */
|
||||||
lck->data = NULL;
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
lck->data = parse_share_modes(lck, key, data);
|
state->lck = talloc(state->mem_ctx, struct share_mode_lock);
|
||||||
|
if (state->lck == NULL) {
|
||||||
|
DEBUG(0, ("talloc failed\n"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
state->lck->data = parse_share_modes(state->lck, key, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*******************************************************************
|
/*******************************************************************
|
||||||
@ -646,23 +655,16 @@ static void fetch_share_mode_unlocked_parser(
|
|||||||
struct share_mode_lock *fetch_share_mode_unlocked(TALLOC_CTX *mem_ctx,
|
struct share_mode_lock *fetch_share_mode_unlocked(TALLOC_CTX *mem_ctx,
|
||||||
struct file_id id)
|
struct file_id id)
|
||||||
{
|
{
|
||||||
struct share_mode_lock *lck;
|
struct fetch_share_mode_unlocked_state state = { .mem_ctx = mem_ctx };
|
||||||
TDB_DATA key = locking_key(&id);
|
TDB_DATA key = locking_key(&id);
|
||||||
NTSTATUS status;
|
NTSTATUS status;
|
||||||
|
|
||||||
lck = talloc(mem_ctx, struct share_mode_lock);
|
|
||||||
if (lck == NULL) {
|
|
||||||
DEBUG(0, ("talloc failed\n"));
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
status = dbwrap_parse_record(
|
status = dbwrap_parse_record(
|
||||||
lock_db, key, fetch_share_mode_unlocked_parser, lck);
|
lock_db, key, fetch_share_mode_unlocked_parser, &state);
|
||||||
if (!NT_STATUS_IS_OK(status) ||
|
if (!NT_STATUS_IS_OK(status)) {
|
||||||
(lck->data == NULL)) {
|
|
||||||
TALLOC_FREE(lck);
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
return lck;
|
return state.lck;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct share_mode_forall_state {
|
struct share_mode_forall_state {
|
||||||
|
Reference in New Issue
Block a user