[libvirt] [PATCH] Set bitmap size when allocating a bitmap

I began noticing a race when reserving VNC ports as described here https://www.redhat.com/archives/libvir-list/2010-November/msg00379.html Turns out that we were not initializing the size field of bitmap struct when allocating the bitmap. This subsequently caused virBitmapSetBit() to fail since bitmap->size is 0, hence we never actually reserved the port. --- src/util/bitmap.c | 1 + 1 files changed, 1 insertions(+), 0 deletions(-) diff --git a/src/util/bitmap.c b/src/util/bitmap.c index 1b0c9da..9741668 100644 --- a/src/util/bitmap.c +++ b/src/util/bitmap.c @@ -73,6 +73,7 @@ virBitmapPtr virBitmapAlloc(size_t size) return NULL; } + bitmap->size = size; return bitmap; } -- 1.7.3.1

On 12/22/2010 01:02 PM, Jim Fehlig wrote:
I began noticing a race when reserving VNC ports as described here
https://www.redhat.com/archives/libvir-list/2010-November/msg00379.html
Turns out that we were not initializing the size field of bitmap struct when allocating the bitmap. This subsequently caused virBitmapSetBit() to fail since bitmap->size is 0, hence we never actually reserved the port. --- src/util/bitmap.c | 1 + 1 files changed, 1 insertions(+), 0 deletions(-)
diff --git a/src/util/bitmap.c b/src/util/bitmap.c index 1b0c9da..9741668 100644 --- a/src/util/bitmap.c +++ b/src/util/bitmap.c @@ -73,6 +73,7 @@ virBitmapPtr virBitmapAlloc(size_t size) return NULL; }
+ bitmap->size = size; return bitmap;
Oh dear; sorry for overlooking that when I reviewed your series in May. ACK. -- Eric Blake eblake@redhat.com +1-801-349-2682 Libvirt virtualization library http://libvirt.org

Eric Blake wrote:
On 12/22/2010 01:02 PM, Jim Fehlig wrote:
I began noticing a race when reserving VNC ports as described here
https://www.redhat.com/archives/libvir-list/2010-November/msg00379.html
Turns out that we were not initializing the size field of bitmap struct when allocating the bitmap. This subsequently caused virBitmapSetBit() to fail since bitmap->size is 0, hence we never actually reserved the port. --- src/util/bitmap.c | 1 + 1 files changed, 1 insertions(+), 0 deletions(-)
diff --git a/src/util/bitmap.c b/src/util/bitmap.c index 1b0c9da..9741668 100644 --- a/src/util/bitmap.c +++ b/src/util/bitmap.c @@ -73,6 +73,7 @@ virBitmapPtr virBitmapAlloc(size_t size) return NULL; }
+ bitmap->size = size; return bitmap;
Oh dear; sorry for overlooking that when I reviewed your series in May.
Yeah, that's a rather embarrassing oversight on my part.
ACK.
Thanks. Pushed. Regards, Jim
participants (2)
-
Eric Blake
-
Jim Fehlig