public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Joerg Roedel <joro@8bytes.org>
To: Zhouyi Zhou <zhouzhouyi@gmail.com>
Cc: iommu@lists.linux-foundation.org, linux-kernel@vger.kernel.org,
	Zhouyi Zhou <yizhouzhou@ict.ac.cn>
Subject: Re: [PATCH] IOMMU: iommu module do not check NULL return of kmem_cache_zalloc
Date: Tue, 4 Mar 2014 16:41:18 +0100	[thread overview]
Message-ID: <20140304154117.GF2799@8bytes.org> (raw)
In-Reply-To: <1392084773-16843-1-git-send-email-zhouzhouyi@gmail.com>

On Tue, Feb 11, 2014 at 10:12:53AM +0800, Zhouyi Zhou wrote:
> From: Zhouyi Zhou <yizhouzhou@ict.ac.cn>
> 
> The function iopte_alloc do not check NULL return of kmem_cache_zalloc,
> call iopte_free with argument 0 will panic.
> 
> Signed-off-by: Zhouyi Zhou <yizhouzhou@ict.ac.cn>
> ---
>  drivers/iommu/omap-iommu.c |    3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> 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);

Isn't it better to put the check into iopte_free?


	Joerg



      reply	other threads:[~2014-03-04 15:41 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-02-11  2:12 [PATCH] IOMMU: iommu module do not check NULL return of kmem_cache_zalloc Zhouyi Zhou
2014-03-04 15:41 ` Joerg Roedel [this message]

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=20140304154117.GF2799@8bytes.org \
    --to=joro@8bytes.org \
    --cc=iommu@lists.linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=yizhouzhou@ict.ac.cn \
    --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