Sorry, I misread the code here. There is an `if (!dev)` already, that
I missed and is technically wrong for the __SIMPLE_DEVICE__ case (but
happens to work for the values given).

I won't block this, but don't like it as it adds more `#if defined
__SIMPLE_DEVICE__` to clean up later.

Please mention in the commit message that null-pointers are already
taken care of.

Patch Set 3:
I had a quick look at the pci_dev_path_on_root_debug(). From that I am not sure if I correctly understand the issue. From this I don't get the impression that pci_dev_path_on_root returns false non NULL results. Is that a correct assumption? Or is the entire device tree structure broken cause random errors?

It falls back to dev_find_slot(0, ...) which does not traverse the
device-tree topology but acts solely on the `secondary` bus field.
This can give false positives, because all `secondary` fields are
0 by default and only adapted during PCI enumeration. If a device
in the `devicetree.cb` isn't found during enumeration, the field
stays at 0... pci_dev_path_on_root() doesn't have this problem.


What I am doing here is check if a possible root port is on the devicetree. If it is a non NULL value is returned is it isn't a NULL value is returned and the PCI device shouldn't be accessed. Previously this returned the bug message which is fine for standard accesses but shouldn't be done if you just want to check if a device is on the tree.

Sorry, missed that there was a null check already.

Patch set 3:Code-Review +1

View Change

To view, visit change 38750. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: coreboot
Gerrit-Branch: master
Gerrit-Change-Id: I6bc04e48e97b0a29aef8aa050d3aad116cff1a14
Gerrit-Change-Number: 38750
Gerrit-PatchSet: 3
Gerrit-Owner: Wim Vervoorn <wvervoorn@eltan.com>
Gerrit-Reviewer: Frans Hendriks <fhendriks@eltan.com>
Gerrit-Reviewer: Nico Huber <nico.h@gmx.de>
Gerrit-Reviewer: Patrick Rudolph <siro@das-labor.org>
Gerrit-Reviewer: Wim Vervoorn <wvervoorn@eltan.com>
Gerrit-Reviewer: build bot (Jenkins) <no-reply@coreboot.org>
Gerrit-CC: Paul Menzel <paulepanter@users.sourceforge.net>
Gerrit-Comment-Date: Tue, 11 Feb 2020 09:32:16 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment