Re: [PATCH 3/3] KVM: s390: memory leak in guest debug handling

Matthew Rosato <[email protected]> Tue, 4 Aug 2026 10:52:12 -0400
Newsgroups org.kernel.vger.kvm,org.kernel.vger.linux-s390
Message-ID <[email protected]>
On 8/4/26 8:06 AM, Christian Borntraeger wrote:
> bp_data is freed only for the error case by kfree(bp_data).
> Every successful KVM_SET_GUEST_DEBUG will leak bp_data.
> 
> Fixes: 27291e2165b6 ("KVM: s390: hardware support for guest debugging")
> Signed-off-by: Christian Borntraeger <[email protected]>

Maybe worth re-visiting for potential __free() usage as a follow on and
replace the goto logic.

But as a fix this LGTM.

Reviewed-by: Matthew Rosato <[email protected]>


> ---
>  arch/s390/kvm/guestdbg.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/arch/s390/kvm/guestdbg.c b/arch/s390/kvm/guestdbg.c
> index 69835e1d4f20..4c02dbebb2eb 100644
> --- a/arch/s390/kvm/guestdbg.c
> +++ b/arch/s390/kvm/guestdbg.c
> @@ -267,6 +267,7 @@ int kvm_s390_import_bp_data(struct kvm_vcpu *vcpu,
>  	vcpu->arch.guestdbg.hw_bp_info = bp_info;
>  	vcpu->arch.guestdbg.nr_hw_wp = nr_wp;
>  	vcpu->arch.guestdbg.hw_wp_info = wp_info;
> +	kfree(bp_data);
>  	return 0;
>  error:
>  	kfree(bp_data);