From: sashiko-bot@kernel.org
To: "Koichiro Den" <den@valinux.co.jp>
Cc: ntb@lists.linux.dev, linux-pci@vger.kernel.org
Subject: Re: [PATCH v5 1/2] PCI: endpoint: pci-epf-vntb: Use a local epf pointer in interrupt setup
Date: Thu, 15 Oct 2026 01:54:52 +0000 [thread overview]
Message-ID: <sashiko-outbox-172128@kernel.org> (raw)
In-Reply-To: <20261015014402.2976188-2-den@valinux.co.jp>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] pci-epf-vntb: missing NULL check for epc_features causes dereference crash
--
commit 696d7d5432aa89730866d2e53e0d664d75343cd2
Author: Koichiro Den <den@valinux.co.jp>
PCI: endpoint: pci-epf-vntb: Use a local epf pointer in interrupt setup
This commit introduces a local epf pointer to simplify device access and
shorten repeated pointer dereferences in epf_ntb_configure_interrupt.
> diff --git a/drivers/pci/endpoint/functions/pci-epf-vntb.c b/drivers/pci/endpoint/functions/pci-epf-vntb.c
> index a11f9260ee860..d74402ea10bf6 100644
> --- a/drivers/pci/endpoint/functions/pci-epf-vntb.c
> +++ b/drivers/pci/endpoint/functions/pci-epf-vntb.c
> @@ -545,12 +545,14 @@ static int epf_ntb_config_spad_bar_alloc(struct epf_ntb *ntb)
> static int epf_ntb_configure_interrupt(struct epf_ntb *ntb)
> {
> const struct pci_epc_features *epc_features;
> + struct pci_epf *epf = ntb->epf;
> struct device *dev;
> int ret;
>
> - dev = &ntb->epf->dev;
> + dev = &epf->dev;
>
> - epc_features = pci_epc_get_features(ntb->epf->epc, ntb->epf->func_no, ntb->epf->vfunc_no);
> + epc_features = pci_epc_get_features(epf->epc, epf->func_no,
> + epf->vfunc_no);
>
> if (!(epc_features->msix_capable || epc_features->msi_capable)) {
[Severity: High]
Could this regression result in a NULL pointer dereference crash?
Looking at pci_epc_get_features() in pci-epc-core.c, it returns NULL for
invalid configurations or if the driver is missing get_features operations:
pci_epc_get_features() {
if (!pci_epc_function_is_valid(epc, func_no, vfunc_no))
return NULL;
if (!epc->ops->get_features)
return NULL;
...
}
If a user configures the endpoint with an invalid function number via
configfs, pci_epc_get_features() will return NULL. Because the returned
epc_features pointer is unconditionally dereferenced in the if statement
above, would it be safer to add a NULL check before inspecting the
structure?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261015014402.2976188-1-den@valinux.co.jp?part=1
next prev parent reply other threads:[~2026-10-15 1:54 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-15 1:44 [PATCH v5 0/2] PCI: endpoint: pci-epf-vntb: Honor MSI-X selection Koichiro Den
2026-10-15 1:44 ` [PATCH v5 1/2] PCI: endpoint: pci-epf-vntb: Use a local epf pointer in interrupt setup Koichiro Den
2026-10-15 1:54 ` sashiko-bot [this message]
2026-10-15 2:05 ` Frank Li
2026-10-15 1:44 ` [PATCH v5 2/2] PCI: endpoint: pci-epf-vntb: Honor MSI-X selection Koichiro Den
2026-10-15 2:03 ` sashiko-bot
2026-10-15 2:12 ` Frank Li
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=sashiko-outbox-172128@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=den@valinux.co.jp \
--cc=linux-pci@vger.kernel.org \
--cc=ntb@lists.linux.dev \
--cc=sashiko-reviews@lists.linux.dev \
/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