From: "Jan Beulich" <JBeulich@novell.com>
To: Wei Wang2 <wei.wang2@amd.com>
Cc: "xen-devel@lists.xensource.com" <xen-devel@lists.xensource.com>
Subject: Re: [PATCH] msi: Avoid uninitialized msi descriptors
Date: Fri, 13 Aug 2010 13:07:12 +0100 [thread overview]
Message-ID: <4C655190020000780000FB29@vpn.id2.novell.com> (raw)
In-Reply-To: <201008111543.03377.wei.wang2@amd.com>
>>> On 11.08.10 at 15:43, Wei Wang2 <wei.wang2@amd.com> wrote:
> static int __pci_enable_msi(struct msi_info *msi, struct msi_desc **desc)
> {
> int status;
> struct pci_dev *pdev;
>+ struct msi_desc *old_desc;
>
> ASSERT(spin_is_locked(&pcidevs_lock));
> pdev = pci_get_pdev(msi->bus, msi->devfn);
> if ( !pdev )
> return -ENODEV;
>
>- if ( find_msi_entry(pdev, msi->irq, PCI_CAP_ID_MSI) )
>+ old_desc = find_msi_entry(pdev, msi->irq, PCI_CAP_ID_MSI);
>+ if ( old_desc )
> {
> dprintk(XENLOG_WARNING, "irq %d has already mapped to MSI on "
> "device %02x:%02x.%01x.\n", msi->irq, msi->bus,
> PCI_SLOT(msi->devfn), PCI_FUNC(msi->devfn));
>+ *desc = old_desc;
While I agree to this part, ...
> return 0;
> }
>
>- if ( find_msi_entry(pdev, -1, PCI_CAP_ID_MSIX) )
>+ old_desc = find_msi_entry(pdev, -1, PCI_CAP_ID_MSIX);
>+ if ( old_desc )
> {
> dprintk(XENLOG_WARNING, "MSI-X is already in use on "
> "device %02x:%02x.%01x\n", msi->bus,
> PCI_SLOT(msi->devfn), PCI_FUNC(msi->devfn));
>- return 0;
>+ pci_disable_msi(old_desc);
... I don't think this one's right: Admittedly I should have changed
the return value from 0 to an actual error (e.g. -EBUSY) - I simply
overlooked that after doing the copy-and-paste operation.
Whether disabling and switching to the alternative mechanism
is the right thing to do here I don't know. But I'm pretty certain
that old_desc may now be leaked, as msi_free_irq() isn't being
called on it and set_irq_msi() also doesn't check whether
irq_desc[].msi_desc is already non-NULL.
Same thing (obviously) for the second part of the changes.
Jan
next prev parent reply other threads:[~2010-08-13 12:07 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-08-11 13:43 [PATCH] msi: Avoid uninitialized msi descriptors Wei Wang2
2010-08-13 12:07 ` Jan Beulich [this message]
-- strict thread matches above, loose matches on Subject: below --
2010-08-11 17:09 Dante Cinco
2010-08-11 17:36 ` Keir Fraser
2010-08-12 13:30 ` Wei Wang2
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=4C655190020000780000FB29@vpn.id2.novell.com \
--to=jbeulich@novell.com \
--cc=wei.wang2@amd.com \
--cc=xen-devel@lists.xensource.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;
as well as URLs for NNTP newsgroup(s).