From: "Zhouyi Zhou" <yizhouzhou@ict.ac.cn>
To: "Zhouyi Zhou" <zhouzhouyi@gmail.com>
Cc: linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org,
kvm-ppc@vger.kernel.org, kvm@vger.kernel.org,
"David Woodhouse" <dwmw2@infradead.org>,
"Joerg Roedel" <joro@8bytes.org>,
"Benjamin Herrenschmidt" <benh@kernel.crashing.org>
Subject: ping: re: [PATCH 1/1] kernel code that do not handle NULL return of kmem_cache_zalloc
Date: Mon, 2 Dec 2013 11:07:04 +0800 (GMT+08:00) [thread overview]
Message-ID: <e9c283.a967.142b14600da.Coremail.yizhouzhou@ict.ac.cn> (raw)
In-Reply-To: <1385549465-15945-1-git-send-email-yizhouzhou@ict.ac.cn>
ping
> I do a grep for kmem_cache_zalloc and kmem_cache_alloc
> in kernel tree, and find some code do not handle NULL
> return of kmem_cache_zalloc correctly
>
>
> Signed-off-by: Zhouyi Zhou <yizhouzhou@ict.ac.cn>
> ---
> arch/powerpc/kvm/book3s_32_mmu_host.c | 5 +++++
> drivers/iommu/omap-iommu.c | 3 ++-
> fs/jffs2/malloc.c | 4 ++++
> 3 files changed, 11 insertions(+), 1 deletion(-)
>
> diff --git a/arch/powerpc/kvm/book3s_32_mmu_host.c b/arch/powerpc/kvm/book3s_32_mmu_host.c
> index 3a0abd2..5fac89d 100644
> --- a/arch/powerpc/kvm/book3s_32_mmu_host.c
> +++ b/arch/powerpc/kvm/book3s_32_mmu_host.c
> @@ -243,6 +243,11 @@ next_pteg:
> /* Now tell our Shadow PTE code about the new page */
>
> pte = kvmppc_mmu_hpte_cache_next(vcpu);
> + if (!pte) {
> + kvm_release_pfn_clean(hpaddr >> PAGE_SHIFT);
> + r = -EAGAIN;
> + goto out;
> + }
>
> dprintk_mmu("KVM: %c%c Map 0x%llx: [%lx] 0x%llx (0x%llx) -> %lx\n",
> orig_pte->may_write ? 'w' : '-',
> diff --git a/drivers/iommu/omap-iommu.c b/drivers/iommu/omap-iommu.c
> index bcd78a7..5155714 100644
> --- a/drivers/iommu/omap-iommu.c
> +++ b/drivers/iommu/omap-iommu.c
> @@ -551,7 +551,8 @@ static u32 *iopte_alloc(struct omap_iommu *obj, u32 *iopgd, u32 da)
> dev_vdbg(obj->dev, "%s: a new pte:%p\n", __func__, iopte);
> } else {
> /* We raced, free the reduniovant table */
> - iopte_free(iopte);
> + if (iopte)
> + iopte_free(iopte);
> }
>
> pte_ready:
> diff --git a/fs/jffs2/malloc.c b/fs/jffs2/malloc.c
> index 4f47aa2..58e2336 100644
> --- a/fs/jffs2/malloc.c
> +++ b/fs/jffs2/malloc.c
> @@ -287,6 +287,8 @@ struct jffs2_xattr_datum *jffs2_alloc_xattr_datum(void)
> {
> struct jffs2_xattr_datum *xd;
> xd = kmem_cache_zalloc(xattr_datum_cache, GFP_KERNEL);
> + if (!xd)
> + return NULL;
> dbg_memalloc("%p\n", xd);
>
> xd->class = RAWNODE_CLASS_XATTR_DATUM;
> @@ -305,6 +307,8 @@ struct jffs2_xattr_ref *jffs2_alloc_xattr_ref(void)
> {
> struct jffs2_xattr_ref *ref;
> ref = kmem_cache_zalloc(xattr_ref_cache, GFP_KERNEL);
> + if (!ref)
> + return NULL;
> dbg_memalloc("%p\n", ref);
>
> ref->class = RAWNODE_CLASS_XATTR_REF;
> --
> 1.7.10.4
>
next prev parent reply other threads:[~2013-12-02 3:15 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-11-27 10:51 Zhouyi Zhou
2013-12-02 3:07 ` Zhouyi Zhou [this message]
2013-12-02 9:54 ` ping: " Alexander Graf
2013-12-02 7:19 ping: " zhouzhouyi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=e9c283.a967.142b14600da.Coremail.yizhouzhou@ict.ac.cn \
--to=yizhouzhou@ict.ac.cn \
--cc=benh@kernel.crashing.org \
--cc=dwmw2@infradead.org \
--cc=joro@8bytes.org \
--cc=kvm-ppc@vger.kernel.org \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=zhouzhouyi@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®