discover/boot: Fix use-after-free in boot()
[petitboot] / discover / boot.c
index 8ad83beb6a98673ecfea8844406da4c0f662078f..e7a72d4330c67d4586912cfb2e2c2994f3095203 100644 (file)
@@ -371,8 +371,6 @@ no_load:
        if (clean_dtb)
                unlink(boot_task->local_dtb);
 
-       talloc_free(boot_task);
-
        if (!result) {
                update_status(status_fn, status_arg, BOOT_STATUS_INFO,
                                "performing kexec reboot");
@@ -385,5 +383,7 @@ no_load:
                }
        }
 
+       talloc_free(boot_task);
+
        return result;
 }