From: Bjorn Helgaas <helgaas@kernel.org>
To: Shradha Todi <shradha.t@samsung.com>
Cc: linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org,
kishon@ti.com, lorenzo.pieralisi@arm.com, bhelgaas@google.com,
pankaj.dubey@samsung.com, Sriram Dash <sriram.dash@samsung.com>
Subject: Re: [PATCH v2] PCI: endpoint: Fix NULL pointer dereference for ->get_features()
Date: Wed, 23 Dec 2020 14:34:03 -0600 [thread overview]
Message-ID: <20201223203403.GA320059@bjorn-Precision-5520> (raw)
In-Reply-To: <1608306316-32096-1-git-send-email-shradha.t@samsung.com>
On Fri, Dec 18, 2020 at 09:15:16PM +0530, Shradha Todi wrote:
> get_features ops of pci_epc_ops may return NULL, causing NULL pointer
> dereference in pci_epf_test_bind function. Let us add a check for
> pci_epc_feature pointer in pci_epf_test_bind before we access it to
> avoid any such NULL pointer dereference and return -ENOTSUPP in case
> pci_epc_feature is not found.
Can you add a Fixes: tag to identify where this broke to help people
decide where to backport the fix?
> Reviewed-by: Pankaj Dubey <pankaj.dubey@samsung.com>
> Signed-off-by: Sriram Dash <sriram.dash@samsung.com>
> Signed-off-by: Shradha Todi <shradha.t@samsung.com>
> ---
> v2:
> rebase on v1
> v1: https://lore.kernel.org/patchwork/patch/1208269/
>
> drivers/pci/endpoint/functions/pci-epf-test.c | 13 ++++++++-----
> 1 file changed, 8 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/pci/endpoint/functions/pci-epf-test.c b/drivers/pci/endpoint/functions/pci-epf-test.c
> index 66723d5..f1842e6 100644
> --- a/drivers/pci/endpoint/functions/pci-epf-test.c
> +++ b/drivers/pci/endpoint/functions/pci-epf-test.c
> @@ -835,13 +835,16 @@ static int pci_epf_test_bind(struct pci_epf *epf)
> return -EINVAL;
>
> epc_features = pci_epc_get_features(epc, epf->func_no);
> - if (epc_features) {
> - linkup_notifier = epc_features->linkup_notifier;
> - core_init_notifier = epc_features->core_init_notifier;
> - test_reg_bar = pci_epc_get_first_free_bar(epc_features);
> - pci_epf_configure_bar(epf, epc_features);
> + if (!epc_features) {
> + dev_err(&epf->dev, "epc_features not implemented\n");
> + return -EOPNOTSUPP;
> }
>
> + linkup_notifier = epc_features->linkup_notifier;
> + core_init_notifier = epc_features->core_init_notifier;
> + test_reg_bar = pci_epc_get_first_free_bar(epc_features);
> + pci_epf_configure_bar(epf, epc_features);
> +
> epf_test->test_reg_bar = test_reg_bar;
> epf_test->epc_features = epc_features;
>
> --
> 2.7.4
>
next prev parent reply other threads:[~2020-12-23 20:34 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <CGME20201218154704epcas5p1446559adbd4a5b267a4c940b5f744970@epcas5p1.samsung.com>
2020-12-18 15:45 ` Shradha Todi
2020-12-23 20:34 ` Bjorn Helgaas [this message]
2020-12-24 5:50 ` Shradha Todi
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=20201223203403.GA320059@bjorn-Precision-5520 \
--to=helgaas@kernel.org \
--cc=bhelgaas@google.com \
--cc=kishon@ti.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=lorenzo.pieralisi@arm.com \
--cc=pankaj.dubey@samsung.com \
--cc=shradha.t@samsung.com \
--cc=sriram.dash@samsung.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
all inboxes | Powered by JetHome®