diff mbox series

[v2,1/5] xen/bitmap: fix bitmap_fill with zero-sized bitmap

Message ID eddbab0d58a78f10882ea0271d5b38b4e38763d1.1557431250.git-series.marmarek@invisiblethingslab.com (mailing list archive)
State Superseded
Headers show
Series Fixes for large framebuffer, placed above 4GB | expand

Commit Message

Marek Marczykowski-Górecki May 9, 2019, 7:48 p.m. UTC
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>
---
 xen/include/xen/bitmap.h | 2 ++
 1 file changed, 2 insertions(+)
diff mbox series

Patch

diff --git a/xen/include/xen/bitmap.h b/xen/include/xen/bitmap.h
index fe3c720..0430c1c 100644
--- a/xen/include/xen/bitmap.h
+++ b/xen/include/xen/bitmap.h
@@ -126,6 +126,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 */