Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1717501
| From | David Hildenbrand <david@redhat.com> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | Re: [PATCH] fix memory leak on kvm_vm_ioctl_create_spapr_tce |
| Date | 2017-08-22 17:30 +0200 |
| Message-ID | <uhjhT-4dB-9@gated-at.bofh.it> (permalink) |
| References | <uhiFb-3Hr-3@gated-at.bofh.it> <uhj8d-49K-9@gated-at.bofh.it> |
| Organization | Red Hat GmbH |
On 22.08.2017 17:15, David Hildenbrand wrote:
> On 22.08.2017 16:28, nixiaoming wrote:
>> miss kfree(stt) when anon_inode_getfd return fail
>> so add check anon_inode_getfd return val, and kfree stt
>>
>> Signed-off-by: nixiaoming <nixiaoming@huawei.com>
>> ---
>> arch/powerpc/kvm/book3s_64_vio.c | 5 ++++-
>> 1 file changed, 4 insertions(+), 1 deletion(-)
>>
>> diff --git a/arch/powerpc/kvm/book3s_64_vio.c b/arch/powerpc/kvm/book3s_64_vio.c
>> index a160c14..a0b4459 100644
>> --- a/arch/powerpc/kvm/book3s_64_vio.c
>> +++ b/arch/powerpc/kvm/book3s_64_vio.c
>> @@ -341,8 +341,11 @@ long kvm_vm_ioctl_create_spapr_tce(struct kvm *kvm,
>>
>> mutex_unlock(&kvm->lock);
>>
>> - return anon_inode_getfd("kvm-spapr-tce", &kvm_spapr_tce_fops,
>> + ret = anon_inode_getfd("kvm-spapr-tce", &kvm_spapr_tce_fops,
>> stt, O_RDWR | O_CLOEXEC);
>> + if (ret < 0)
>> + goto fail;
>> + return ret;
>>
>> fail:
>> if (stt) {
>>
>
>
> stt has already been added to kvm->arch.spapr_tce_tables, so freeing it
> is evil IMHO. I don't know that code, so I don't know if there is some
> other place that will make sure that everything in
> kvm->arch.spapr_tce_tables will properly get freed, even when no release
> function has been called (kvm_spapr_tce_release).
>
If it is really not freed, than also kvm_put_kvm(stt->kvm) is missing.
--
Thanks,
David
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[PATCH] fix memory leak on kvm_vm_ioctl_create_spapr_tce nixiaoming <nixiaoming@huawei.com> - 2017-08-22 16:50 +0200
Re: [PATCH] fix memory leak on kvm_vm_ioctl_create_spapr_tce David Hildenbrand <david@redhat.com> - 2017-08-22 17:20 +0200
Re: [PATCH] fix memory leak on kvm_vm_ioctl_create_spapr_tce David Hildenbrand <david@redhat.com> - 2017-08-22 17:30 +0200
Re:Re: [PATCH] fix memory leak on kvm_vm_ioctl_create_spapr_tce Nixiaoming <nixiaoming@huawei.com> - 2017-08-23 03:50 +0200
Re: Re: [PATCH] fix memory leak on kvm_vm_ioctl_create_spapr_tce Paul Mackerras <paulus@ozlabs.org> - 2017-08-23 08:10 +0200
Re: [PATCH] fix memory leak on kvm_vm_ioctl_create_spapr_tce David Hildenbrand <david@redhat.com> - 2017-08-23 10:30 +0200
Re: [PATCH] fix memory leak on kvm_vm_ioctl_create_spapr_tce David Hildenbrand <david@redhat.com> - 2017-08-23 11:20 +0200
答复: [PATCH] fix memory leak on kvm_vm_ioctl_create_spapr_tce Nixiaoming <nixiaoming@huawei.com> - 2017-08-23 12:20 +0200
Re: [PATCH] fix memory leak on kvm_vm_ioctl_create_spapr_tce Nixiaoming <nixiaoming@huawei.com> - 2017-08-24 03:10 +0200
csiph-web