From: Pan Bian <bianpan201603@163.com>
To: Bjorn Helgaas <bhelgaas@google.com>,
Lukas Wunner <lukas@wunner.de>,
Keith Busch <keith.busch@intel.com>,
"Rafael J. Wysocki" <rafael.j.wysocki@intel.com>,
Mika Westerberg <mika.westerberg@linux.intel.com>,
linux-pci@vger.kernel.org
Cc: linux-kernel@vger.kernel.org, Pan Bian <bianpan2016@163.com>
Subject: [PATCH 1/1] PCI: check return value of pci_find_ext_capability
Date: Sun, 23 Apr 2017 22:00:20 +0800 [thread overview]
Message-ID: <1492956020-32271-1-git-send-email-bianpan201603@163.com> (raw)
From: Pan Bian <bianpan2016@163.com>
Function pci_find_ext_capability() will returns 0 on failure, and its
return value should be checked before it is used. However, in function
pcie_port_enable_msix(), its return value is not checked. This patch
adds the check.
Signed-off-by: Pan Bian <bianpan2016@163.com>
---
drivers/pci/pcie/portdrv_core.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/pci/pcie/portdrv_core.c b/drivers/pci/pcie/portdrv_core.c
index cea504f..001951d 100644
--- a/drivers/pci/pcie/portdrv_core.c
+++ b/drivers/pci/pcie/portdrv_core.c
@@ -103,6 +103,8 @@ static int pcie_port_enable_msix(struct pci_dev *dev, int *irqs, int mask)
* interrupt message."
*/
pos = pci_find_ext_capability(dev, PCI_EXT_CAP_ID_ERR);
+ if (!pos)
+ goto out_free_irqs;
pci_read_config_dword(dev, pos + PCI_ERR_ROOT_STATUS, ®32);
entry = reg32 >> 27;
if (entry >= nr_entries)
--
1.9.1
next reply other threads:[~2017-04-23 14:00 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-04-23 14:00 Pan Bian [this message]
2017-04-24 10:36 ` [PATCH 1/1] PCI: check return value of pci_find_ext_capability Mika Westerberg
2017-04-25 19:31 ` Bjorn Helgaas
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=1492956020-32271-1-git-send-email-bianpan201603@163.com \
--to=bianpan201603@163.com \
--cc=bhelgaas@google.com \
--cc=bianpan2016@163.com \
--cc=keith.busch@intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=lukas@wunner.de \
--cc=mika.westerberg@linux.intel.com \
--cc=rafael.j.wysocki@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 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).