[PATCH] target/arm/kvm: Don't free migration-blocker reason on failure

Peter Maydell posted 1 patch 1 month, 2 weeks ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20260223173232.453165-1-peter.maydell@linaro.org
Maintainers: Peter Maydell <peter.maydell@linaro.org>, Paolo Bonzini <pbonzini@redhat.com>
target/arm/kvm.c | 1 -
1 file changed, 1 deletion(-)
[PATCH] target/arm/kvm: Don't free migration-blocker reason on failure
Posted by Peter Maydell 1 month, 2 weeks ago
The migrate_add_blocker() function documents that if it fails it will
free the Error it is passed via its reasonp argument and set reasonp
to NULL.  That means that in kvm_arm_enable_mte() we don't need to
call error_free(mte_migration_blocker) in the failure codepath.
Doing so is harmless because error_free(NULL) is permitted and does
nothing, but we can remove the unnecessary code.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
---
This seems to be the only caller of migrate_add_blocker() that
was doing this.
---
 target/arm/kvm.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/target/arm/kvm.c b/target/arm/kvm.c
index ded582e0da..388766c846 100644
--- a/target/arm/kvm.c
+++ b/target/arm/kvm.c
@@ -2540,7 +2540,6 @@ void kvm_arm_enable_mte(Object *cpuobj, Error **errp)
         error_setg(&mte_migration_blocker,
                    "Live migration disabled due to MTE enabled");
         if (migrate_add_blocker(&mte_migration_blocker, errp)) {
-            error_free(mte_migration_blocker);
             return;
         }
 
-- 
2.43.0
Re: [PATCH] target/arm/kvm: Don't free migration-blocker reason on failure
Posted by Pierrick Bouvier 1 month, 2 weeks ago
On 2/23/26 9:32 AM, Peter Maydell wrote:
> The migrate_add_blocker() function documents that if it fails it will
> free the Error it is passed via its reasonp argument and set reasonp
> to NULL.  That means that in kvm_arm_enable_mte() we don't need to
> call error_free(mte_migration_blocker) in the failure codepath.
> Doing so is harmless because error_free(NULL) is permitted and does
> nothing, but we can remove the unnecessary code.
> 
> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
> ---
> This seems to be the only caller of migrate_add_blocker() that
> was doing this.
> ---
>   target/arm/kvm.c | 1 -
>   1 file changed, 1 deletion(-)
> 

Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>