From: Lars Ellenberg Date: Fri, 13 Jan 2023 12:35:37 +0000 (+0100) Subject: drbd: interval tree: make removing an "empty" interval a no-op X-Git-Tag: v6.6.17~5251^2~107 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=2990ca29f36171e052ea42d8464ec2e21cf4485a;p=platform%2Fkernel%2Flinux-rpi.git 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 Signed-off-by: Christoph Böhmwalder Link: https://lore.kernel.org/r/20230113123538.144276-8-christoph.boehmwalder@linbit.com Signed-off-by: Jens Axboe --- diff --git a/drivers/block/drbd/drbd_interval.c b/drivers/block/drbd/drbd_interval.c index 5024ffd6143d..b6aaf0d4d85b 100644 --- a/drivers/block/drbd/drbd_interval.c +++ b/drivers/block/drbd/drbd_interval.c @@ -95,6 +95,10 @@ drbd_contains_interval(struct rb_root *root, sector_t sector, void drbd_remove_interval(struct rb_root *root, struct drbd_interval *this) { + /* avoid endless loop */ + if (drbd_interval_empty(this)) + return; + rb_erase_augmented(&this->rb, root, &augment_callbacks); }