Message ID | 20230327175457.735903-1-mhal@rbox.co (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | KVM: Don't kfree(NULL) on kzalloc() failure in kvm_assign_ioeventfd_idx() | expand |
On Mon, Mar 27, 2023, Michal Luczaj wrote: > On kzalloc() failure, taking the `goto fail` path 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. > Signed-off-by: Michal Luczaj <mhal@rbox.co> > --- Reviewed-by: Sean Christopherson <seanjc@google.com>
On 27/3/23 19:54, Michal Luczaj wrote: > 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> > --- > virt/kvm/eventfd.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
On 3/27/23 19:54, Michal Luczaj wrote: > On kzalloc() failure, taking the `goto fail` path leads to kfree(NULL). > Such no-op has no use. Move it out. Few weeks later, a polite ping. thanks, Michal
On Mon, 27 Mar 2023 19:54:57 +0200, Michal Luczaj wrote: > On kzalloc() failure, taking the `goto fail` path 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
diff --git a/virt/kvm/eventfd.c b/virt/kvm/eventfd.c index 2a3ed401ce46..385368e706e5 100644 --- a/virt/kvm/eventfd.c +++ b/virt/kvm/eventfd.c @@ -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;
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> --- virt/kvm/eventfd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)