* [PATCH] KVM: PPC: Book3S HV: NULL check before some freeing functions is not needed. [not found] <1543760930050-1499171309-0-diffsplit-thomas@m3y3r.de> @ 2018-12-02 20:52 ` Thomas Meyer 2018-12-03 0:06 ` Suraj Jitindar Singh 0 siblings, 1 reply; 2+ messages in thread From: Thomas Meyer @ 2018-12-02 20:52 UTC (permalink / raw) To: paulus, benh, mpe, kvm-ppc, linuxppc-dev, linux-kernel NULL check before some freeing functions is not needed. Signed-off-by: Thomas Meyer <thomas@m3y3r.de> --- diff -u -p a/arch/powerpc/kvm/book3s_hv_nested.c b/arch/powerpc/kvm/book3s_hv_nested.c --- a/arch/powerpc/kvm/book3s_hv_nested.c +++ b/arch/powerpc/kvm/book3s_hv_nested.c @@ -1252,8 +1252,7 @@ static long int __kvmhv_nested_page_faul rmapp = &memslot->arch.rmap[gfn - memslot->base_gfn]; ret = kvmppc_create_pte(kvm, gp->shadow_pgtable, pte, n_gpa, level, mmu_seq, gp->shadow_lpid, rmapp, &n_rmap); - if (n_rmap) - kfree(n_rmap); + kfree(n_rmap); if (ret == -EAGAIN) ret = RESUME_GUEST; /* Let the guest try again */ ^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] KVM: PPC: Book3S HV: NULL check before some freeing functions is not needed. 2018-12-02 20:52 ` [PATCH] KVM: PPC: Book3S HV: NULL check before some freeing functions is not needed Thomas Meyer @ 2018-12-03 0:06 ` Suraj Jitindar Singh 0 siblings, 0 replies; 2+ messages in thread From: Suraj Jitindar Singh @ 2018-12-03 0:06 UTC (permalink / raw) To: Thomas Meyer, paulus, benh, mpe, kvm-ppc, linuxppc-dev, linux-kernel On Sun, 2018-12-02 at 21:52 +0100, Thomas Meyer wrote: > NULL check before some freeing functions is not needed. Technically true, however I think a comment should be added then to make it clearer to someone reading the code why this is ok. See below. Suraj. > > Signed-off-by: Thomas Meyer <thomas@m3y3r.de> > --- > > diff -u -p a/arch/powerpc/kvm/book3s_hv_nested.c > b/arch/powerpc/kvm/book3s_hv_nested.c > --- a/arch/powerpc/kvm/book3s_hv_nested.c > +++ b/arch/powerpc/kvm/book3s_hv_nested.c > @@ -1252,8 +1252,7 @@ static long int __kvmhv_nested_page_faul > rmapp = &memslot->arch.rmap[gfn - memslot->base_gfn]; > ret = kvmppc_create_pte(kvm, gp->shadow_pgtable, pte, n_gpa, > level, > mmu_seq, gp->shadow_lpid, rmapp, > &n_rmap); > - if (n_rmap) > - kfree(n_rmap); > + kfree(n_rmap); e.g. /* n_rmap set to NULL in kvmppc_create_pte if reference preserved */ > if (ret == -EAGAIN) > ret = RESUME_GUEST; /* Let the guest try > again */ > ^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2018-12-03 0:09 UTC | newest] Thread overview: 2+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- [not found] <1543760930050-1499171309-0-diffsplit-thomas@m3y3r.de> 2018-12-02 20:52 ` [PATCH] KVM: PPC: Book3S HV: NULL check before some freeing functions is not needed Thomas Meyer 2018-12-03 0:06 ` Suraj Jitindar Singh
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).