Message ID | 20220909095006.65440-1-metikaya@amazon.co.uk (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | [1/2] KVM: x86/xen: Remove redundant NULL check | expand |
Channeling Jim, s/redundant/superfluous. Redundant would imply there's a !NULL check in close proximity. On Fri, Sep 09, 2022, Metin Kaya wrote: > 'kvm' cannot be NULL if we are at that point. Please make the changelog a standalone thing, i.e. don't rely on the shortlog to provide context. Some subsystems prefer making the changelog a continuation of the shortlog, but IMO it makes life unnecessarily painful for reviewers and archaeologists, e.g. I don't even see the subject/shortlog right now. Please elaborate on what guarantees that this in the changelog. It's trivial to see from the code, but the fact that it's trivial to document is all the more reason to provide a one-liner. E.g. Remove a superfluous check that @kvm is non-NULL in kvm_xen_eventfd_deassign(), the pointer has already been dereferenced multiple times before the check, and the sole caller unconditionally passes in a valid pointer. > This bug was discovered and resolved using Coverity Static Analysis > Security Testing (SAST) by Synopsys, Inc. > > Fixes: 2fd6df2f2b47 ("KVM: x86/xen: intercept EVTCHNOP_send from > guests") Don't wrap fixes tags. > Signed-off-by: Metin Kaya <metikaya@amazon.co.uk> > --- > arch/x86/kvm/xen.c | 3 +-- > 1 file changed, 1 insertion(+), 2 deletions(-) > > diff --git a/arch/x86/kvm/xen.c b/arch/x86/kvm/xen.c > index 280cb5dc7341..f2e09481f633 100644 > --- a/arch/x86/kvm/xen.c > +++ b/arch/x86/kvm/xen.c > @@ -1734,8 +1734,7 @@ static int kvm_xen_eventfd_deassign(struct kvm *kvm, u32 port) > if (!evtchnfd) > return -ENOENT; > > - if (kvm) > - synchronize_srcu(&kvm->srcu); > + synchronize_srcu(&kvm->srcu); > if (!evtchnfd->deliver.port.port) > eventfd_ctx_put(evtchnfd->deliver.eventfd.ctx); > kfree(evtchnfd); > -- > 2.37.1 >
diff --git a/arch/x86/kvm/xen.c b/arch/x86/kvm/xen.c index 280cb5dc7341..f2e09481f633 100644 --- a/arch/x86/kvm/xen.c +++ b/arch/x86/kvm/xen.c @@ -1734,8 +1734,7 @@ static int kvm_xen_eventfd_deassign(struct kvm *kvm, u32 port) if (!evtchnfd) return -ENOENT; - if (kvm) - synchronize_srcu(&kvm->srcu); + synchronize_srcu(&kvm->srcu); if (!evtchnfd->deliver.port.port) eventfd_ctx_put(evtchnfd->deliver.eventfd.ctx); kfree(evtchnfd);
'kvm' cannot be NULL if we are at that point. This bug was discovered and resolved using Coverity Static Analysis Security Testing (SAST) by Synopsys, Inc. Fixes: 2fd6df2f2b47 ("KVM: x86/xen: intercept EVTCHNOP_send from guests") Signed-off-by: Metin Kaya <metikaya@amazon.co.uk> --- arch/x86/kvm/xen.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)