Skip to content

Commit

Permalink
pc-dimm: fix error messages if no slots were defined
Browse files Browse the repository at this point in the history
If no slots were defined we try to allocate an empty bitmap, which
fails.

Signed-off-by: David Hildenbrand <david@redhat.com>
Reviewed-by: Marcel Apfelbaum <marcel@redhat.com>
Reviewed-by: Thomas Huth <thuth@redhat.com>
Message-Id: <20180427120515.24067-1-david@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
  • Loading branch information
davidhildenbrand authored and bonzini committed May 11, 2018
1 parent 814e111 commit 3ff333e
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion hw/mem/pc-dimm.c
Original file line number Diff line number Diff line change
Expand Up @@ -118,9 +118,16 @@ static int pc_dimm_slot2bitmap(Object *obj, void *opaque)

int pc_dimm_get_free_slot(const int *hint, int max_slots, Error **errp)
{
unsigned long *bitmap = bitmap_new(max_slots);
unsigned long *bitmap;
int slot = 0;

if (max_slots <= 0) {
error_setg(errp, "no slots where allocated, please specify "
"the 'slots' option");
return slot;
}

bitmap = bitmap_new(max_slots);
object_child_foreach(qdev_get_machine(), pc_dimm_slot2bitmap, bitmap);

/* check if requested slot is not occupied */
Expand Down

0 comments on commit 3ff333e

Please sign in to comment.