]> xenbits.xensource.com Git - people/royger/xen.git/commitdiff
xen/rangeset: fix incorrect subtraction
authorRoger Pau Monne <roger.pau@citrix.com>
Wed, 2 Apr 2025 16:50:46 +0000 (18:50 +0200)
committerRoger Pau Monne <roger.pau@citrix.com>
Fri, 11 Apr 2025 10:20:10 +0000 (12:20 +0200)
Given the following rangset operation:

{ [0, 1], [4, 5] } - { [3, 4] }

The current rangeset logic will output a rangeset:

{ [0, 2], [5, 5] }

This is incorrect, and also has the undesirable property of being bogus in
a way that the resulting rangeset is expanded.

Fix this by making sure the bounds are correctly checked before modifying
the previous range.

Fixes: 484a058c4828 ('Add auto-destructing per-domain rangeset data structure...')
Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
xen/common/rangeset.c

index b75590f90744042967b142b4586752145cf465b3..e7587103908712cf278c36a436bfd6de58423380 100644 (file)
@@ -227,7 +227,8 @@ int rangeset_remove_range(
 
         if ( x->s < s )
         {
-            x->e = s - 1;
+            if ( x->e >= s )
+                x->e = s - 1;
             x = next_range(r, x);
         }