Re: [PATCH v5 9/9] KVM: s390: Return failure in case of failure in kvm_s390_set_cmma_bits()

From: Christian Borntraeger

Date: Tue Jun 23 2026 - 06:35:40 EST


Am 23.06.26 um 12:33 schrieb Claudio Imbrenda:
On Tue, 23 Jun 2026 11:30:24 +0200
Christian Borntraeger <borntraeger@xxxxxxxxxx> wrote:

Am 22.06.26 um 18:07 schrieb Claudio Imbrenda:
If the allocation of the bits array failed, kvm_s390_set_cmma_bits()
would return 0 instead of an error code.

Rework the function to use the __free() macros and thus simplify the
code flow; when the above mentioned allocation fails, simply return
-ENOMEM.

Fixes: e38c884df921 ("KVM: s390: Switch to new gmap")
Signed-off-by: Claudio Imbrenda <imbrenda@xxxxxxxxxxxxx>
---
arch/s390/kvm/kvm-s390.c | 18 +++++++-----------
1 file changed, 7 insertions(+), 11 deletions(-)

diff --git a/arch/s390/kvm/kvm-s390.c b/arch/s390/kvm/kvm-s390.c
index cdd8b41d24ed..27d6004132d2 100644
--- a/arch/s390/kvm/kvm-s390.c
+++ b/arch/s390/kvm/kvm-s390.c
@@ -2282,8 +2282,8 @@ static int kvm_s390_get_cmma_bits(struct kvm *kvm,
static int kvm_s390_set_cmma_bits(struct kvm *kvm,
const struct kvm_s390_cmma_log *args)
{
- struct kvm_s390_mmu_cache *mc;
- u8 *bits = NULL;
+ struct kvm_s390_mmu_cache *mc __free(kvm_s390_mmu_cache) = NULL;
+ u8 *bits __free(kvfree) = NULL;

why kvfree and not vfree?

because vfree does not exist as cleanup macro: __free(vfree) would not
compile

adding vfree would be outside the scope of this patch

With that

Reviewed-by: Christian Borntraeger <borntraeger@xxxxxxxxxxxxx>