Skip to content

Commit 70b0bc4

Browse files
mmhalsean-jc
authored andcommitted
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. Signed-off-by: Michal Luczaj <mhal@rbox.co> Reviewed-by: Sean Christopherson <seanjc@google.com> Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> Link: https://lore.kernel.org/r/20230327175457.735903-1-mhal@rbox.co Signed-off-by: Sean Christopherson <seanjc@google.com>
1 parent c9d6015 commit 70b0bc4

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

virt/kvm/eventfd.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -889,9 +889,9 @@ static int kvm_assign_ioeventfd_idx(struct kvm *kvm,
889889

890890
unlock_fail:
891891
mutex_unlock(&kvm->slots_lock);
892+
kfree(p);
892893

893894
fail:
894-
kfree(p);
895895
eventfd_ctx_put(eventfd);
896896

897897
return ret;

0 commit comments

Comments
 (0)