diff --git a/lib/device/bcache.c b/lib/device/bcache.c index b0edf2806..04d49f165 100644 --- a/lib/device/bcache.c +++ b/lib/device/bcache.c @@ -1376,7 +1376,10 @@ bool bcache_invalidate_fd(struct bcache *cache, int fd) it.success = true; it.it.visit = _invalidate_v; radix_tree_iterate(cache->rtree, k.bytes, k.bytes + sizeof(k.parts.fd), &it.it); - radix_tree_remove_prefix(cache->rtree, k.bytes, k.bytes + sizeof(k.parts.fd)); + + if (it.success) + radix_tree_remove_prefix(cache->rtree, k.bytes, k.bytes + sizeof(k.parts.fd)); + return it.success; }