[PATCH 06/11] fdc: Fix fallback=auto error handling

Markus Armbruster posted 11 patches 5 years, 9 months ago
Maintainers: Paolo Bonzini <pbonzini@redhat.com>, Richard Henderson <rth@twiddle.net>, Kevin Wolf <kwolf@redhat.com>, "Michael S. Tsirkin" <mst@redhat.com>, Gerd Hoffmann <kraxel@redhat.com>, Jason Wang <jasowang@redhat.com>, Anthony Perard <anthony.perard@citrix.com>, Stefano Stabellini <sstabellini@kernel.org>, John Snow <jsnow@redhat.com>, Paul Durrant <paul@xen.org>, Juan Quintela <quintela@redhat.com>, Hailiang Zhang <zhang.zhanghailiang@huawei.com>, Max Reitz <mreitz@redhat.com>, "Dr. David Alan Gilbert" <dgilbert@redhat.com>, "Daniel P. Berrangé" <berrange@redhat.com>, Peter Maydell <peter.maydell@linaro.org>, "Gonglei (Arei)" <arei.gonglei@huawei.com>
There is a newer version of this series
[PATCH 06/11] fdc: Fix fallback=auto error handling
Posted by Markus Armbruster 5 years, 9 months ago
fdctrl_realize_common() rejects fallback=auto.  Used by devices
"isa-fdc", "sysbus-fdc", "SUNW,fdtwo".  The error handling is broken:

    $ qemu-system-x86_64 -nodefaults -device isa-fdc,fallback=auto,driveA=fd0 -drive if=none,id=fd0
    **
    ERROR:/work/armbru/qemu/hw/block/fdc.c:434:pick_drive_type: assertion failed: (drv->drive != FLOPPY_DRIVE_TYPE_AUTO)
    Aborted (core dumped)

Cause: fdctrl_realize_common() neglects to bail out after setting the
error.  Fix that.

Fixes: a73275dd6fc3bfda33165bebc28e0c33c20cb0a0
Cc: John Snow <jsnow@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
---
 hw/block/fdc.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/hw/block/fdc.c b/hw/block/fdc.c
index 33bc9e2f92..9628cc171e 100644
--- a/hw/block/fdc.c
+++ b/hw/block/fdc.c
@@ -2615,6 +2615,7 @@ static void fdctrl_realize_common(DeviceState *dev, FDCtrl *fdctrl,
 
     if (fdctrl->fallback == FLOPPY_DRIVE_TYPE_AUTO) {
         error_setg(errp, "Cannot choose a fallback FDrive type of 'auto'");
+        return;
     }
 
     /* Fill 'command_to_handler' lookup table */
-- 
2.21.1


Re: [PATCH 06/11] fdc: Fix fallback=auto error handling
Posted by Philippe Mathieu-Daudé 5 years, 9 months ago
On 4/20/20 10:32 AM, Markus Armbruster wrote:
> fdctrl_realize_common() rejects fallback=auto.  Used by devices
> "isa-fdc", "sysbus-fdc", "SUNW,fdtwo".  The error handling is broken:
> 
>      $ qemu-system-x86_64 -nodefaults -device isa-fdc,fallback=auto,driveA=fd0 -drive if=none,id=fd0
>      **
>      ERROR:/work/armbru/qemu/hw/block/fdc.c:434:pick_drive_type: assertion failed: (drv->drive != FLOPPY_DRIVE_TYPE_AUTO)
>      Aborted (core dumped)
> 
> Cause: fdctrl_realize_common() neglects to bail out after setting the
> error.  Fix that.
> 
> Fixes: a73275dd6fc3bfda33165bebc28e0c33c20cb0a0
> Cc: John Snow <jsnow@redhat.com>
> Signed-off-by: Markus Armbruster <armbru@redhat.com>
> ---
>   hw/block/fdc.c | 1 +
>   1 file changed, 1 insertion(+)
> 
> diff --git a/hw/block/fdc.c b/hw/block/fdc.c
> index 33bc9e2f92..9628cc171e 100644
> --- a/hw/block/fdc.c
> +++ b/hw/block/fdc.c
> @@ -2615,6 +2615,7 @@ static void fdctrl_realize_common(DeviceState *dev, FDCtrl *fdctrl,
>   
>       if (fdctrl->fallback == FLOPPY_DRIVE_TYPE_AUTO) {
>           error_setg(errp, "Cannot choose a fallback FDrive type of 'auto'");
> +        return;
>       }
>   
>       /* Fill 'command_to_handler' lookup table */
> 

Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>