All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jisheng Zhang <Jisheng.Zhang@synaptics.com>
To: Aditya Pakki <pakki001@umn.edu>
Cc: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>,
	"kjlu@umn.edu" <kjlu@umn.edu>, Will Deacon <will.deacon@arm.com>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"linux-pci@vger.kernel.org" <linux-pci@vger.kernel.org>,
	Bjorn Helgaas <bhelgaas@google.com>,
	"linux-arm-kernel@lists.infradead.org" 
	<linux-arm-kernel@lists.infradead.org>
Subject: Re: [PATCH] PCI: Fix to avoid potential NULL pointer dereference
Date: Tue, 19 Mar 2019 05:36:36 +0000	[thread overview]
Message-ID: <20190319132909.7d37b6cf@xhacker.debian> (raw)
In-Reply-To: <20190319002630.12485-1-pakki001@umn.edu>

On Mon, 18 Mar 2019 19:26:30 -0500 Aditya Pakki wrote:

> 
> In gen_pci_probe, of_match_node can return a NULL pointer in case of

This could not happen. If the probe is called, it means OF registered a
device with a valid compatible string, so of_match_node cannot be NULL.

> failure. The patch avoids a NULL pointer dereference in such a scenario.
> 
> Signed-off-by: Aditya Pakki <pakki001@umn.edu>
> ---
>  drivers/pci/controller/pci-host-generic.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/drivers/pci/controller/pci-host-generic.c b/drivers/pci/controller/pci-host-generic.c
> index dea3ec7592a2..85f473f50e96 100644
> --- a/drivers/pci/controller/pci-host-generic.c
> +++ b/drivers/pci/controller/pci-host-generic.c
> @@ -83,6 +83,8 @@ static int gen_pci_probe(struct platform_device *pdev)
>         struct pci_ecam_ops *ops;
> 
>         of_id = of_match_node(gen_pci_of_match, pdev->dev.of_node);
> +       if (!of_id)
> +               return -ENXIO;
>         ops = (struct pci_ecam_ops *)of_id->data;
> 
>         return pci_host_common_probe(pdev, ops);
> --
> 2.17.1
> 
> 
> _______________________________________________
> linux-arm-kernel mailing list
> linux-arm-kernel@lists.infradead.org
> https://urldefense.proofpoint.com/v2/url?u=http-3A__lists.infradead.org_mailman_listinfo_linux-2Darm-2Dkernel&d=DwICAg&c=7dfBJ8cXbWjhc0BhImu8wQ&r=wlaKTGoVCDxOzHc2QUzpzGEf9oY3eidXlAe3OF1omvo&m=Aaw3ijENR3L1GJbf1JjDlPa-S8-6UwqqXN40ECdoisk&s=ByG7jEMATcZVHKP-JW7j4efNcV-iAfJDFTEzC8Ba7oc&e=


WARNING: multiple messages have this Message-ID (diff)
From: Jisheng Zhang <Jisheng.Zhang@synaptics.com>
To: Aditya Pakki <pakki001@umn.edu>
Cc: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>,
	"kjlu@umn.edu" <kjlu@umn.edu>, Will Deacon <will.deacon@arm.com>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"linux-pci@vger.kernel.org" <linux-pci@vger.kernel.org>,
	Bjorn Helgaas <bhelgaas@google.com>,
	"linux-arm-kernel@lists.infradead.org"
	<linux-arm-kernel@lists.infradead.org>
Subject: Re: [PATCH] PCI: Fix to avoid potential NULL pointer dereference
Date: Tue, 19 Mar 2019 05:36:36 +0000	[thread overview]
Message-ID: <20190319132909.7d37b6cf@xhacker.debian> (raw)
In-Reply-To: <20190319002630.12485-1-pakki001@umn.edu>

On Mon, 18 Mar 2019 19:26:30 -0500 Aditya Pakki wrote:

> 
> In gen_pci_probe, of_match_node can return a NULL pointer in case of

This could not happen. If the probe is called, it means OF registered a
device with a valid compatible string, so of_match_node cannot be NULL.

> failure. The patch avoids a NULL pointer dereference in such a scenario.
> 
> Signed-off-by: Aditya Pakki <pakki001@umn.edu>
> ---
>  drivers/pci/controller/pci-host-generic.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/drivers/pci/controller/pci-host-generic.c b/drivers/pci/controller/pci-host-generic.c
> index dea3ec7592a2..85f473f50e96 100644
> --- a/drivers/pci/controller/pci-host-generic.c
> +++ b/drivers/pci/controller/pci-host-generic.c
> @@ -83,6 +83,8 @@ static int gen_pci_probe(struct platform_device *pdev)
>         struct pci_ecam_ops *ops;
> 
>         of_id = of_match_node(gen_pci_of_match, pdev->dev.of_node);
> +       if (!of_id)
> +               return -ENXIO;
>         ops = (struct pci_ecam_ops *)of_id->data;
> 
>         return pci_host_common_probe(pdev, ops);
> --
> 2.17.1
> 
> 
> _______________________________________________
> linux-arm-kernel mailing list
> linux-arm-kernel@lists.infradead.org
> https://urldefense.proofpoint.com/v2/url?u=http-3A__lists.infradead.org_mailman_listinfo_linux-2Darm-2Dkernel&d=DwICAg&c=7dfBJ8cXbWjhc0BhImu8wQ&r=wlaKTGoVCDxOzHc2QUzpzGEf9oY3eidXlAe3OF1omvo&m=Aaw3ijENR3L1GJbf1JjDlPa-S8-6UwqqXN40ECdoisk&s=ByG7jEMATcZVHKP-JW7j4efNcV-iAfJDFTEzC8Ba7oc&e=


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

  reply	other threads:[~2019-03-19  5:36 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-03-19  0:26 [PATCH] PCI: Fix to avoid potential NULL pointer dereference Aditya Pakki
2019-03-19  0:26 ` Aditya Pakki
2019-03-19  5:36 ` Jisheng Zhang [this message]
2019-03-19  5:36   ` Jisheng Zhang

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=20190319132909.7d37b6cf@xhacker.debian \
    --to=jisheng.zhang@synaptics.com \
    --cc=bhelgaas@google.com \
    --cc=kjlu@umn.edu \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=lorenzo.pieralisi@arm.com \
    --cc=pakki001@umn.edu \
    --cc=will.deacon@arm.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.