isa-superio: validate floppy.count value

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>
This commit is contained in:
Paolo Bonzini 2024-01-29 14:32:38 +01:00
parent deac624f22
commit 41514c0a77

View File

@ -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) {