]> xenbits.xensource.com Git - people/dwmw2/xen.git/commitdiff
bitmap: fix bitmap_fill with zero-sized bitmap
authorMarek Marczykowski-Górecki <marmarek@invisiblethingslab.com>
Thu, 6 Jun 2019 12:08:10 +0000 (14:08 +0200)
committerJan Beulich <jbeulich@suse.com>
Thu, 6 Jun 2019 12:08:10 +0000 (14:08 +0200)
When bitmap_fill(..., 0) is called, do not try to write anything. Before
this patch, it tried to write almost LONG_MAX, surely overwriting
something.

Signed-off-by: Marek Marczykowski-Górecki <marmarek@invisiblethingslab.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
master commit: 93df28be2d4f620caf18109222d046355ac56327
master date: 2019-05-13 10:12:00 +0200

xen/include/xen/bitmap.h

index e2a368691e311c52aa6a186939ee4217f3fe60c4..ab3b113fd1eabcc6b8b14d524b042bc3974e8283 100644 (file)
@@ -132,6 +132,8 @@ static inline void bitmap_fill(unsigned long *dst, int nbits)
        size_t nlongs = BITS_TO_LONGS(nbits);
 
        switch (nlongs) {
+       case 0:
+               break;
        default:
                memset(dst, -1, (nlongs - 1) * sizeof(unsigned long));
                /* fall through */