]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
KVM: s390: vsie: Fix memory leak when unshadowing
authorClaudio Imbrenda <imbrenda@linux.ibm.com>
Tue, 19 May 2026 15:01:10 +0000 (17:01 +0200)
committerClaudio Imbrenda <imbrenda@linux.ibm.com>
Fri, 22 May 2026 09:25:10 +0000 (11:25 +0200)
When performing a partial unshadowing, the rmap was being leaked.

Add the missing kfree().

Fixes: a2c17f9270cc ("KVM: s390: New gmap code")
Signed-off-by: Claudio Imbrenda <imbrenda@linux.ibm.com>
Reviewed-by: Christoph Schlameuss <schlameuss@linux.ibm.com>
Reviewed-by: Christian Borntraeger <borntraeger@linux.ibm.com>
Signed-off-by: Christian Borntraeger <borntraeger@linux.ibm.com>
arch/s390/kvm/gmap.c

index 3c26e35af0ef7c4d97008e460b77a038ef0051bf..fd19277619809b8e89243f887d1cca0d996b4938 100644 (file)
@@ -1143,8 +1143,10 @@ void _gmap_handle_vsie_unshadow_event(struct gmap *parent, gfn_t gfn)
                }
                scoped_guard(spinlock, &sg->host_to_rmap_lock)
                        head = radix_tree_delete(&sg->host_to_rmap, gfn);
-               gmap_for_each_rmap_safe(rmap, rnext, head)
+               gmap_for_each_rmap_safe(rmap, rnext, head) {
                        gmap_unshadow_level(sg, rmap->r_gfn, rmap->level);
+                       kfree(rmap);
+               }
        }
 }