public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* Re: Re: [PATCH] IOMMU: iommu module do not check NULL return of kmem_cache_zalloc
@ 2014-03-05  2:31 Zhouyi Zhou
  2014-03-05  7:53 ` Joerg Roedel
  0 siblings, 1 reply; 2+ messages in thread
From: Zhouyi Zhou @ 2014-03-05  2:31 UTC (permalink / raw)
  To: joro, iommu, linux-kernel; +Cc: Zhouyi Zhou, Zhouyi Zhou

From: Zhouyi Zhou <zhouzhouyi@gmail.com>

On Tue, 4 Mar 2014 16:41:18 +0100
Joerg Roedel <joro@8bytes.org> wrote:

> 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
> 
> 
Thanks Joerg for reviewing
Checking the null pointer in iopte_free guarantees kmem_cache_free
is happy all the time.

Signed-off-by: Zhouyi Zhou <yizhouzhou@ict.ac.cn>
Signed-off-by: Joerg Roedel <joro@8bytes.org>

---
 drivers/iommu/omap-iommu.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/drivers/iommu/omap-iommu.c b/drivers/iommu/omap-iommu.c
index bcd78a7..51211e8 100644
--- a/drivers/iommu/omap-iommu.c
+++ b/drivers/iommu/omap-iommu.c
@@ -523,7 +523,8 @@ static void flush_iopte_range(u32 *first, u32 *last)
 static void iopte_free(u32 *iopte)
 {
 	/* Note: freed iopte's must be clean ready for re-use */
-	kmem_cache_free(iopte_cachep, iopte);
+	if (iopte)
+		kmem_cache_free(iopte_cachep, iopte);
 }
 
 static u32 *iopte_alloc(struct omap_iommu *obj, u32 *iopgd, u32 da)



^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: Re: [PATCH] IOMMU: iommu module do not check NULL return of kmem_cache_zalloc
  2014-03-05  2:31 Re: [PATCH] IOMMU: iommu module do not check NULL return of kmem_cache_zalloc Zhouyi Zhou
@ 2014-03-05  7:53 ` Joerg Roedel
  0 siblings, 0 replies; 2+ messages in thread
From: Joerg Roedel @ 2014-03-05  7:53 UTC (permalink / raw)
  To: Zhouyi Zhou; +Cc: iommu, linux-kernel, Zhouyi Zhou

On Wed, Mar 05, 2014 at 10:31:17AM +0800, Zhouyi Zhou wrote:
> Thanks Joerg for reviewing
> Checking the null pointer in iopte_free guarantees kmem_cache_free
> is happy all the time.

Can you send this as a new patch in a new thread please?

Thanks,

	Joerg



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2014-03-05  7:53 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-03-05  2:31 Re: [PATCH] IOMMU: iommu module do not check NULL return of kmem_cache_zalloc Zhouyi Zhou
2014-03-05  7:53 ` Joerg Roedel

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox