discover: Ensure destroy_device is called on reinit
[petitboot] / discover / device-handler.c
index 64095f10d723c41f702caa2d3a9fcd2d0754eed1..d2b50b5e36c3e170ad478ca12bbd93e819fcef50 100644 (file)
@@ -330,9 +330,11 @@ void device_handler_reinit(struct device_handler *handler)
        list_init(&handler->unresolved_boot_options);
 
        /* drop all devices */
-       for (i = 0; i < handler->n_devices; i++)
+       for (i = 0; i < handler->n_devices; i++) {
                discover_server_notify_device_remove(handler->server,
                                handler->devices[i]->device);
+               talloc_free(handler->devices[i]);
+       }
 
        talloc_free(handler->devices);
        handler->devices = NULL;