Skip to content

Commit

Permalink
ida: Remove assertions that an ID was allocated
Browse files Browse the repository at this point in the history
Nobody finds value in asserting that an ID that we try to free was
already allocated, so just remove those assertions.

Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
  • Loading branch information
Matthew Wilcox (Oracle) committed Jul 11, 2022
1 parent 85656ec commit 69cb69e
Showing 1 changed file with 4 additions and 10 deletions.
14 changes: 4 additions & 10 deletions lib/idr.c
Original file line number Diff line number Diff line change
Expand Up @@ -491,25 +491,22 @@ void ida_free(struct ida *ida, unsigned int id)
struct ida_bitmap *bitmap;
unsigned long flags;

if ((int)id < 0)
return;

xas_lock_irqsave(&xas, flags);
bitmap = xas_load(&xas);

if (xa_is_value(bitmap)) {
unsigned long v = xa_to_value(bitmap);
if (bit >= BITS_PER_XA_VALUE)
goto err;
goto not_found;
if (!(v & (1UL << bit)))
goto err;
goto not_found;
v &= ~(1UL << bit);
if (!v)
goto delete;
xas_store(&xas, xa_mk_value(v));
} else {
if (!test_bit(bit, bitmap->bitmap))
goto err;
goto not_found;
__clear_bit(bit, bitmap->bitmap);
xas_set_mark(&xas, XA_FREE_MARK);
if (bitmap_empty(bitmap->bitmap, IDA_BITMAP_BITS)) {
Expand All @@ -518,11 +515,8 @@ void ida_free(struct ida *ida, unsigned int id)
xas_store(&xas, NULL);
}
}
not_found:
xas_unlock_irqrestore(&xas, flags);
return;
err:
xas_unlock_irqrestore(&xas, flags);
WARN(1, "ida_free called for id=%d which is not allocated.\n", id);
}
EXPORT_SYMBOL(ida_free);

Expand Down

0 comments on commit 69cb69e

Please sign in to comment.