Skip to content

Commit b4da11c

Browse files
committed
fixup! landlock/coalesced_hash: Implement insert
1 parent faf8f41 commit b4da11c

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

security/landlock/coalesced_hash.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,7 @@ __h_insert_get_next_free(struct h_insert_scratch *scratch,
152152
element_is_empty_t is_empty_func)
153153
{
154154
h_index_t index_to_ret = scratch->next_free_index;
155+
void *free_slot;
155156

156157
if (WARN_ON_ONCE(index_to_ret >= scratch->table_size)) {
157158
/*
@@ -161,6 +162,16 @@ __h_insert_get_next_free(struct h_insert_scratch *scratch,
161162
return 0;
162163
}
163164

165+
free_slot = scratch->table + index_to_ret * scratch->elem_size;
166+
while (!is_empty_func(free_slot)) {
167+
if (WARN_ON_ONCE(index_to_ret == 0)) {
168+
/* We unexpectedly used up all slots. */
169+
return 0;
170+
}
171+
index_to_ret--;
172+
free_slot = scratch->table + index_to_ret * scratch->elem_size;
173+
}
174+
164175
if (index_to_ret == 0)
165176
scratch->next_free_index = scratch->table_size;
166177
else

0 commit comments

Comments
 (0)