Skip to content

Commit

Permalink
isa-superio: validate floppy.count value
Browse files Browse the repository at this point in the history
Ensure that the value is valid; it can only be zero or one.
And never create a floppy disk controller if it is zero.

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
  • Loading branch information
bonzini committed Feb 16, 2024
1 parent deac624 commit 41514c0
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion hw/isa/isa-superio.c
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,9 @@ static void isa_superio_realize(DeviceState *dev, Error **errp)
}

/* Floppy disc */
if (!k->floppy.is_enabled || k->floppy.is_enabled(sio, 0)) {
assert(k->floppy.count <= 1);
if (k->floppy.count &&
(!k->floppy.is_enabled || k->floppy.is_enabled(sio, 0))) {
isa = isa_new(TYPE_ISA_FDC);
d = DEVICE(isa);
if (k->floppy.get_iobase) {
Expand Down

0 comments on commit 41514c0

Please sign in to comment.