Re: [PATCH] KVM: Add separate helper for putting borrowed reference to kvm

Paolo Bonzini
2019-11-27T18:32:40Z

[-- Attachment #1.1: Type: text/plain, Size: 679 bytes --]

On 27/11/19 19:24, Leonardo Bras wrote:
> By what I could undestand up to now, these functions that use borrowed
> references can only be called while the reference (file descriptor)
> exists.
> So, suppose these threads, where:
> - T1 uses a borrowed reference, and
> - T2 is releasing the reference (close, release):

Nit: T2 is releasing the *last* reference (as implied by your reference
to close/release).

>
> T1 | T2
> kvm_get_kvm() |
> ... | kvm_put_kvm()
> kvm_put_kvm_no_destroy() |
>
> The above would not trigger a use-after-free bug, but will cause a
> memory leak. Is my above understanding right?

Yes, this is correct.

Paolo

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]