mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Bjorn Helgaas <helgaas@kernel.org>
To: Pankaj Dubey <pankaj.dubey@samsung.com>
Cc: linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org,
	Kishon Vijay Abraham I <kishon@ti.com>,
	Bjorn Helgaas <bhelgaas@google.com>
Subject: Re: [PATCH] PCI: endpoint: handle probable NULL pointer access
Date: Tue, 24 Oct 2017 15:02:00 -0500	[thread overview]
Message-ID: <20171024200200.GE21840@bhelgaas-glaptop.roam.corp.google.com> (raw)
In-Reply-To: <1507780677-7983-1-git-send-email-pankaj.dubey@samsung.com>

On Thu, Oct 12, 2017 at 09:27:57AM +0530, Pankaj Dubey wrote:
> controller_group allocation in pci_ep_cfs_init function can fail
> so we should have a check while using it in pci_ep_cfs_add_epc_group
> for registering group, else we will hit NULL pointer access.
> 
> This patch adds required check for the same and returns -EPROBE_DEFER,
> so that endpoint controller driver probe can be reattempted later
> in case controller_group is not allocated because pci_ep_cfs_init is
> not yet called.
> 
> Signed-off-by: Pankaj Dubey <pankaj.dubey@samsung.com>

Looking for Kishon's ack here.

> ---
>  drivers/pci/endpoint/pci-ep-cfs.c   | 7 ++++++-
>  drivers/pci/endpoint/pci-epc-core.c | 4 ++++
>  2 files changed, 10 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/pci/endpoint/pci-ep-cfs.c b/drivers/pci/endpoint/pci-ep-cfs.c
> index 424fdd6..3cac818 100644
> --- a/drivers/pci/endpoint/pci-ep-cfs.c
> +++ b/drivers/pci/endpoint/pci-ep-cfs.c
> @@ -172,7 +172,12 @@ struct config_group *pci_ep_cfs_add_epc_group(const char *name)
>  	group = &epc_group->group;
>  
>  	config_group_init_type_name(group, name, &pci_epc_type);
> -	ret = configfs_register_group(controllers_group, group);
> +
> +	if (controllers_group)
> +		ret = configfs_register_group(controllers_group, group);
> +	else
> +		ret = -EPROBE_DEFER;
> +
>  	if (ret) {
>  		pr_err("failed to register configfs group for %s\n", name);
>  		goto err_register_group;
> diff --git a/drivers/pci/endpoint/pci-epc-core.c b/drivers/pci/endpoint/pci-epc-core.c
> index 42c2a11..d327a2a 100644
> --- a/drivers/pci/endpoint/pci-epc-core.c
> +++ b/drivers/pci/endpoint/pci-epc-core.c
> @@ -518,6 +518,10 @@ __pci_epc_create(struct device *dev, const struct pci_epc_ops *ops,
>  		goto put_dev;
>  
>  	epc->group = pci_ep_cfs_add_epc_group(dev_name(dev));
> +	if (IS_ERR(epc->group)) {
> +		ret = -EPROBE_DEFER;
> +		goto put_dev;
> +	}
>  
>  	return epc;
>  
> -- 
> 2.7.4
> 

  reply	other threads:[~2017-10-24 20:02 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CGME20171012035806epcas1p16df484a0565cfe780416253710464a8f@epcas1p1.samsung.com>
2017-10-12  3:57 ` Pankaj Dubey
2017-10-24 20:02   ` Bjorn Helgaas [this message]
2017-10-25 12:02     ` Kishon Vijay Abraham I
2017-10-28 10:43       ` Pankaj Dubey
2017-11-06 19:29         ` 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=20171024200200.GE21840@bhelgaas-glaptop.roam.corp.google.com \
    --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=pankaj.dubey@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®