From: Philippe Mathieu-Daudé Date: Fri, 20 Oct 2023 10:08:21 +0000 (+0200) Subject: hw/isa/i82378: Propagate error if PC_SPEAKER device creation failed X-Git-Tag: v8.2.0-rc0~19^2~22 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=2798ee63b03a8a67017c4fa5ef21fc85bfef67d5;p=thirdparty%2Fqemu.git hw/isa/i82378: Propagate error if PC_SPEAKER device creation failed In commit 40f8214fcd ("hw/audio/pcspk: Inline pcspk_init()") we neglected to give a change to the caller to handle failed device creation cleanly. Respect the caller API contract and propagate the error if creating the PC_SPEAKER device ever failed. This avoid yet another bad API use to be taken as example and copy / pasted all over the code base. Reported-by: Bernhard Beschow Suggested-by: Markus Armbruster Reviewed-by: Richard Henderson Reviewed-by: Bernhard Beschow Signed-off-by: Philippe Mathieu-Daudé Message-Id: <20231020171509.87839-5-philmd@linaro.org> --- diff --git a/hw/isa/i82378.c b/hw/isa/i82378.c index 79ffbb52a00..203b92c2645 100644 --- a/hw/isa/i82378.c +++ b/hw/isa/i82378.c @@ -105,7 +105,9 @@ static void i82378_realize(PCIDevice *pci, Error **errp) /* speaker */ pcspk = isa_new(TYPE_PC_SPEAKER); object_property_set_link(OBJECT(pcspk), "pit", OBJECT(pit), &error_fatal); - isa_realize_and_unref(pcspk, isabus, &error_fatal); + if (!isa_realize_and_unref(pcspk, isabus, errp)) { + return; + } /* 2 82C37 (dma) */ isa_create_simple(isabus, "i82374");