Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

drbd: interval tree: make removing an "empty" interval a no-op

Trying to remove an "empty" (just initialized, or "cleared") interval
from the tree, this results in an endless loop.

As we typically protect the tree with a spinlock_irq,
the result is a hung system.

Be nice to error cleanup code paths, ignore removal of empty intervals.

Signed-off-by: Lars Ellenberg <lars.ellenberg@linbit.com>
Signed-off-by: Christoph Böhmwalder <christoph.boehmwalder@linbit.com>
Link: https://lore.kernel.org/r/20230113123538.144276-8-christoph.boehmwalder@linbit.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>

authored by

Lars Ellenberg and committed by
Jens Axboe
2990ca29 6d9be160

+4
+4
drivers/block/drbd/drbd_interval.c
··· 95 95 void 96 96 drbd_remove_interval(struct rb_root *root, struct drbd_interval *this) 97 97 { 98 + /* avoid endless loop */ 99 + if (drbd_interval_empty(this)) 100 + return; 101 + 98 102 rb_erase_augmented(&this->rb, root, &augment_callbacks); 99 103 } 100 104