All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@oracle.com>
To: walter harms <wharms@bfs.de>
Cc: Suresh Siddha <suresh.b.siddha@intel.com>,
	Ingo Molnar <mingo@elte.hu>, Joerg Roedel <joerg.roedel@amd.com>,
	Thomas Gleixner <tglx@linutronix.de>,
	Youquan Song <youquan.song@intel.com>,
	linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org
Subject: Re: [patch] iommu: off by one in dmar_get_fault_reason()
Date: Sun, 13 May 2012 17:12:14 +0000	[thread overview]
Message-ID: <20120513171214.GD16984@mwanda> (raw)
In-Reply-To: <4FAE595A.6010605@bfs.de>

On Sat, May 12, 2012 at 02:36:42PM +0200, walter harms wrote:
> 
> 
> Am 12.05.2012 12:59, schrieb Dan Carpenter:
> > fault_reason = ARRAY_SIZE(irq_remap_fault_reasons) + 0x20 - 0x20 is one
> > past the end of the array.
> > 
> > Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> > 
> > diff --git a/drivers/iommu/dmar.c b/drivers/iommu/dmar.c
> > index 5ef65cf..9390f3f 100644
> > --- a/drivers/iommu/dmar.c
> > +++ b/drivers/iommu/dmar.c
> > @@ -1057,7 +1057,7 @@ static const char *irq_remap_fault_reasons[] > >  
> >  const char *dmar_get_fault_reason(u8 fault_reason, int *fault_type)
> >  {
> > -	if (fault_reason >= 0x20 && (fault_reason <= 0x20 +
> > +	if (fault_reason >= 0x20 && (fault_reason < 0x20 +
> >  				     ARRAY_SIZE(irq_remap_fault_reasons))) {
> >  		*fault_type = INTR_REMAP;
> >  		return irq_remap_fault_reasons[fault_reason - 0x20];
> 
> perhaps this is more readable:
> if (fault_reason >= 0x20 && (fault_reason - 0x20 < ARRAY_SIZE(irq_remap_fault_reasons)))
> 

Yeah.  Probably you're way is nicer.

regards,
dan carpenter


WARNING: multiple messages have this Message-ID (diff)
From: Dan Carpenter <dan.carpenter@oracle.com>
To: walter harms <wharms@bfs.de>
Cc: Suresh Siddha <suresh.b.siddha@intel.com>,
	Ingo Molnar <mingo@elte.hu>, Joerg Roedel <joerg.roedel@amd.com>,
	Thomas Gleixner <tglx@linutronix.de>,
	Youquan Song <youquan.song@intel.com>,
	linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org
Subject: Re: [patch] iommu: off by one in dmar_get_fault_reason()
Date: Sun, 13 May 2012 20:12:14 +0300	[thread overview]
Message-ID: <20120513171214.GD16984@mwanda> (raw)
In-Reply-To: <4FAE595A.6010605@bfs.de>

On Sat, May 12, 2012 at 02:36:42PM +0200, walter harms wrote:
> 
> 
> Am 12.05.2012 12:59, schrieb Dan Carpenter:
> > fault_reason == ARRAY_SIZE(irq_remap_fault_reasons) + 0x20 - 0x20 is one
> > past the end of the array.
> > 
> > Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> > 
> > diff --git a/drivers/iommu/dmar.c b/drivers/iommu/dmar.c
> > index 5ef65cf..9390f3f 100644
> > --- a/drivers/iommu/dmar.c
> > +++ b/drivers/iommu/dmar.c
> > @@ -1057,7 +1057,7 @@ static const char *irq_remap_fault_reasons[] =
> >  
> >  const char *dmar_get_fault_reason(u8 fault_reason, int *fault_type)
> >  {
> > -	if (fault_reason >= 0x20 && (fault_reason <= 0x20 +
> > +	if (fault_reason >= 0x20 && (fault_reason < 0x20 +
> >  				     ARRAY_SIZE(irq_remap_fault_reasons))) {
> >  		*fault_type = INTR_REMAP;
> >  		return irq_remap_fault_reasons[fault_reason - 0x20];
> 
> perhaps this is more readable:
> if (fault_reason >= 0x20 && (fault_reason - 0x20 < ARRAY_SIZE(irq_remap_fault_reasons)))
> 

Yeah.  Probably you're way is nicer.

regards,
dan carpenter


  parent reply	other threads:[~2012-05-13 17:12 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-05-12 10:59 [patch] iommu: off by one in dmar_get_fault_reason() Dan Carpenter
2012-05-12 10:59 ` Dan Carpenter
2012-05-12 12:36 ` walter harms
2012-05-12 12:36   ` walter harms
2012-05-13 17:09   ` [patch v2] " Dan Carpenter
2012-05-13 17:09     ` Dan Carpenter
2012-05-14 13:42     ` [tip:core/iommu] iommu: Fix " tip-bot for Dan Carpenter
2012-05-13 17:12   ` Dan Carpenter [this message]
2012-05-13 17:12     ` [patch] iommu: " Dan Carpenter

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=20120513171214.GD16984@mwanda \
    --to=dan.carpenter@oracle.com \
    --cc=joerg.roedel@amd.com \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=suresh.b.siddha@intel.com \
    --cc=tglx@linutronix.de \
    --cc=wharms@bfs.de \
    --cc=youquan.song@intel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.