]> git.ipfire.org Git - thirdparty/ipxe.git/commitdiff
[efi] Avoid infinite loops when asked to stop non-existent devices
authorMichael Brown <mcb30@ipxe.org>
Mon, 28 Sep 2015 01:54:53 +0000 (02:54 +0100)
committerMichael Brown <mcb30@ipxe.org>
Mon, 28 Sep 2015 02:20:59 +0000 (03:20 +0100)
Calling EDK2's OpenProtocol() with attributes BY_DRIVER|EXCLUSIVE will
call DisconnectController() in a loop to attempt to dislodge any
existing openers with attributes BY_DRIVER.  The loop will continue
indefinitely until either no such openers remain, or until
DisconnectController() returns an error.

If our driver binding protocol's Stop() method is ever called to
disconnect a device that we are not in fact driving, then return
EFI_DEVICE_ERROR rather than EFI_SUCCESS, in order to break this
potentially infinite loop.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
src/interface/efi/efi_driver.c

index ec67bbcdf1b65c2921ab965addfbb2acd3a9ac08..22aa3ee72fae79e725c95a1bae845661589a3dfa 100644 (file)
@@ -254,7 +254,7 @@ efi_driver_stop ( EFI_DRIVER_BINDING_PROTOCOL *driver __unused,
        if ( ! efidev ) {
                DBGCP ( device, "EFIDRV %s is not started\n",
                        efi_handle_name ( device ) );
-               return 0;
+               return EFI_DEVICE_ERROR;
        }
 
        /* Stop this device */