From: Jiecheng Wu <jasonwood2031@gmail.com>
To: linux-pci@vger.kernel.org
Subject: [PATCH] dpc.c: fix missing return value check of pci_find_ext_capability()
Date: Fri, 17 Aug 2018 16:17:19 +0800 [thread overview]
Message-ID: <20180817081719.11156-1-jasonwood2031@gmail.com> (raw)
Function dpc_probe() defined in drivers/pci/pcie/dpc.c calls pci_find_ext_capability(). Function pci_find_ext_capability() returns the address of the requested extended capability structure within the device's PCI configuration space or 0 if the device does not support it. The return value of this function should be checked against 0.
---
drivers/pci/pcie/dpc.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/pci/pcie/dpc.c b/drivers/pci/pcie/dpc.c
index f03279f..30ff550 100644
--- a/drivers/pci/pcie/dpc.c
+++ b/drivers/pci/pcie/dpc.c
@@ -226,6 +226,8 @@ static int dpc_probe(struct pcie_device *dev)
return -ENOMEM;
dpc->cap_pos = pci_find_ext_capability(pdev, PCI_EXT_CAP_ID_DPC);
+ if (!dpc->cap_pos)
+ return -ENODEV;
dpc->dev = dev;
set_service_data(dev, dpc);
--
2.6.4
next reply other threads:[~2018-08-17 11:19 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-08-17 8:17 Jiecheng Wu [this message]
2018-08-17 10:55 ` [PATCH] dpc.c: fix missing return value check of pci_find_ext_capability() poza
2018-08-17 14:03 ` Keith Busch
2018-09-12 20:51 ` 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=20180817081719.11156-1-jasonwood2031@gmail.com \
--to=jasonwood2031@gmail.com \
--cc=linux-pci@vger.kernel.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 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).