KVM: Don't kfree(NULL) on kzalloc() failure in kvm_assign_ioeventfd_idx()
PATCH 1/1 KVM: Don't kfree(NULL) on kzalloc() failure in kvm_assign_ioeventfd_idx()
On kzalloc() failure, taking the goto fail path leads to kfree(NULL). Such no-op has no use. Move it out.
--- virt/kvm/eventfd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
virt/kvm/eventfd.c +1 -1
@@ -856,9 +856,9 @@ static int kvm_assign_ioeventfd_idx(struct kvm *kvm, unlock_fail:mutex_unlock (&kvm->slots_lock); +kfree (p); fail: -kfree (p);eventfd_ctx_put (eventfd);return ret;
Signature · 1 line
2.40.0
Quoted 2 lines · Michal Luczaj
On
kzalloc()failure, taking thegoto failpath leads to kfree(NULL). Such no-op has no use. Move it out.
Huh, the original commit had the funky code, e.g. it wasn't a case of avoiding labels or anything.
Quoted 2 lines
Signed-off-by Michal Luczaj <[email protected]>---
Quoted 7 lines · Michal Luczaj
On
kzalloc()failure, taking thegoto failpath leads to kfree(NULL). Such no-op has no use. Move it out.Signed-off-by Michal Luczaj <[email protected]>--- virt/kvm/eventfd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 2 lines · Michal Luczaj
On
kzalloc()failure, taking thegoto failpath leads to kfree(NULL). Such no-op has no use. Move it out.
Few weeks later, a polite ping.
thanks,
Michal
Quoted 4 lines · Michal Luczaj
On
kzalloc()failure, taking thegoto failpath leads to kfree(NULL). Such no-op has no use. Move it out.
Applied to kvm-x86 generic, thanks!
[1/1] KVM: Don't kfree(NULL) on kzalloc() failure in kvm_assign_ioeventfd_idx()
https://github.com/kvm-x86/linux/commit/70b0bc4c0a05
--
https://github.com/kvm-x86/linux/tree/next
https://github.com/kvm-x86/linux/tree/fixes