All of lore.kernel.org
 help / color / mirror / Atom feed
From: Yijing Wang <wangyijing@huawei.com>
To: Bjorn Helgaas <bhelgaas@google.com>
Cc: <linux-pci@vger.kernel.org>, <mjg59@coreos.com>,
	<rwhite@pobox.com>, <alex.williamson@redhat.com>
Subject: Re: [PATCH v4 2/3] PCI/ASPM: Fix NULL pointer when find parent pcie_link_state
Date: Mon, 25 May 2015 09:26:21 +0800	[thread overview]
Message-ID: <55627A3D.6070309@huawei.com> (raw)
In-Reply-To: <20150522194207.GI32152@google.com>

> I think we also have a problem here:
> 
>    517  static struct pcie_link_state *alloc_pcie_link_state(struct pci_dev *pdev)
>    518  {
>    519          struct pcie_link_state *link;
>    520  
>    521          link = kzalloc(sizeof(*link), GFP_KERNEL);
>    522          if (!link)
>    523                  return NULL;
>    524          INIT_LIST_HEAD(&link->sibling);
>    525          INIT_LIST_HEAD(&link->children);
>    526          INIT_LIST_HEAD(&link->link);
>    527          link->pdev = pdev;
>    528          if (pci_pcie_type(pdev) == PCI_EXP_TYPE_DOWNSTREAM) {
>    529                  struct pcie_link_state *parent;
>    530                  parent = pdev->bus->parent->self->link_state;
>    531                  if (!parent) {
>    532                          kfree(link);
>    533                          return NULL;
>    534                  }
>    535                  link->parent = parent;
>    536                  list_add(&link->link, &parent->children);
>    537          }
> 
> Before your patch, we could only see Root Ports or Downstream Ports at line
> 528.  Now we may also see Upstream Ports, so I think that test should be
> changed to "if (pci_pcie_type(pdev) != PCI_EXP_TYPE_ROOT_PORT)".

Good catch, thanks!

> 
> Without this change, I think we would allocate pcie_link_state for the
> 03:00.0 Upstream Port in your example, but it would not be connected to the
> tree of links starting at the 00:1c.0 Root Port.
> 
> Do you agree?

Yes.

I will update it.

Thanks!
Yijing.

> 
> Bjorn
> 
> .
> 


-- 
Thanks!
Yijing


  reply	other threads:[~2015-05-25  1:27 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-05-21  7:05 [PATCH v4 1/3] PCI: Add pdev->has_secondary_link to mark pcie link Yijing Wang
2015-05-21  7:05 ` [PATCH v4 2/3] PCI/ASPM: Fix NULL pointer when find parent pcie_link_state Yijing Wang
2015-05-22 19:42   ` Bjorn Helgaas
2015-05-25  1:26     ` Yijing Wang [this message]
2015-05-21  7:05 ` [PATCH v4 3/3] PCI: Use pdev->has_secondary_link to identify pcie link Yijing Wang
2015-05-26 23:58   ` Bjorn Helgaas
2015-05-26 23:57 ` [PATCH v4 1/3] PCI: Add pdev->has_secondary_link to mark " 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=55627A3D.6070309@huawei.com \
    --to=wangyijing@huawei.com \
    --cc=alex.williamson@redhat.com \
    --cc=bhelgaas@google.com \
    --cc=linux-pci@vger.kernel.org \
    --cc=mjg59@coreos.com \
    --cc=rwhite@pobox.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.