All of lore.kernel.org
 help / color / mirror / Atom feed
From: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
To: Andrew Cooper <andrew.cooper3@citrix.com>
Cc: xen-devel <xen-devel@lists.xenproject.org>,
	Wei Liu <wei.liu2@citrix.com>, Jan Beulich <JBeulich@suse.com>
Subject: Re: [PATCH] IOMMU: replace ASSERT()s checking for NULL
Date: Mon, 7 Nov 2016 09:43:13 -0500	[thread overview]
Message-ID: <20161107144313.GG21570@char.us.oracle.com> (raw)
In-Reply-To: <cb1b1cfe-e278-18d7-de6c-c66e4a07c5bc@citrix.com>

On Mon, Nov 07, 2016 at 10:30:37AM +0000, Andrew Cooper wrote:
> On 07/11/16 09:24, Jan Beulich wrote:
> > Avoid NULL derefs on non-debug builds.
> >
> > Coverity ID: 1055650
> >
> > Signed-off-by: Jan Beulich <jbeulich@suse.com>
> 
> Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>

This introduces a bug:
> 
> >
> > --- a/xen/drivers/passthrough/io.c
> > +++ b/xen/drivers/passthrough/io.c
> > @@ -165,7 +165,11 @@ static void pt_irq_time_out(void *data)
> >      spin_lock(&irq_map->dom->event_lock);
> >  
> >      dpci = domain_get_irq_dpci(irq_map->dom);
> > -    ASSERT(dpci);
> > +    if ( unlikely(!dpci) )
> > +    {
> > +        ASSERT_UNREACHABLE();
> > +        return;


As this does not unlock the 'event_lock' spinlock.

But with the ASSERT_UNREACHABLE() we just spin around.

Perhaps a better option would be just to add an 'unlock'
label and then goto to it?

(And ditch the ASSERT altogether?)

> > +    }
> >      list_for_each_entry ( digl, &irq_map->digl_list, list )
> >      {
> >          unsigned int guest_gsi = hvm_pci_intx_gsi(digl->device, digl->intx);
> > @@ -793,7 +797,11 @@ void hvm_dpci_msi_eoi(struct domain *d,
> >  
> >  static void hvm_dirq_assist(struct domain *d, struct hvm_pirq_dpci *pirq_dpci)
> >  {
> > -    ASSERT(d->arch.hvm_domain.irq.dpci);
> > +    if ( unlikely(!d->arch.hvm_domain.irq.dpci) )
> > +    {
> > +        ASSERT_UNREACHABLE();
> > +        return;
> > +    }
> >  
> >      spin_lock(&d->event_lock);
> >      if ( test_and_clear_bool(pirq_dpci->masked) )
> >
> >
> >
> 

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

      parent reply	other threads:[~2016-11-07 14:43 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-11-07  9:24 [PATCH] IOMMU: replace ASSERT()s checking for NULL Jan Beulich
2016-11-07  9:53 ` Jan Beulich
2016-11-07 10:43   ` Andrew Cooper
2016-11-07 13:47     ` Jan Beulich
2016-11-07 10:30 ` Andrew Cooper
2016-11-07 10:41   ` Wei Liu
2016-11-07 14:43   ` Konrad Rzeszutek Wilk [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=20161107144313.GG21570@char.us.oracle.com \
    --to=konrad.wilk@oracle.com \
    --cc=JBeulich@suse.com \
    --cc=andrew.cooper3@citrix.com \
    --cc=wei.liu2@citrix.com \
    --cc=xen-devel@lists.xenproject.org \
    /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.