pci: pci-tegra: fix null pointer assignation.
Subsystems (2)
PATCH 1/1 pci: pci-tegra: fix null pointer assignation.
From: Chali Anis <[email protected]>
the dev might be null, to be sure we move the dev assignation before the pci parent assignation.
--- drivers/pci/pci-tegra.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/pci/pci-tegra.c +1 -1
@@ -1240,13 +1240,13 @@ static int tegra_pcie_probe(struct device *dev)if (!pcie)return -ENOMEM ; + pcie->dev = dev; pcie->pci.parent = pcie->dev;pci_controller_init (&pcie->pci);INIT_LIST_HEAD (&pcie->buses);INIT_LIST_HEAD (&pcie->ports); pcie->soc_data =device_get_match_data (dev); - pcie->dev = dev; err =tegra_pcie_parse_dt (pcie);if (err <0 ) {
Hi,
Am Mittwoch, dem 26.11.2025 um 22:40 -0500 schrieb [email protected]:
Quoted 4 lines
From: Chali Anis <[email protected]>
the dev might be null, to be sure we move the dev assignation before the pci parent assignation.
This isn't worded strongly enough. pcie->dev will absolutely be NULL at the point where it is assigned to pci.parent, which seem like a blatant bug and I don't know how this did ever work or if we just ignored the broken parent device connection.
Other than the commit message needing some adjustment, this change looks correct.
Regards,
Lucas
Quoted 26 lines
Signed-off-by Chali Anis <[email protected]>--- drivers/pci/pci-tegra.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/pci/pci-tegra.c +1
-1@@ -1240,13 +1240,13 @@ static int tegra_pcie_probe(struct device *dev)if (!pcie)return -ENOMEM ; + pcie->dev = dev; pcie->pci.parent = pcie->dev;pci_controller_init (&pcie->pci);INIT_LIST_HEAD (&pcie->buses);INIT_LIST_HEAD (&pcie->ports); pcie->soc_data =device_get_match_data (dev); - pcie->dev = dev; err =tegra_pcie_parse_dt (pcie);if (err <0 ) {
Quoted 6 lines · Lucas Stach
Hi,
Am Mittwoch, dem 26.11.2025 um 22:40 -0500 schrieb [email protected]:
Quoted 2 lines
From: Chali Anis <[email protected]>
Quoted 7 lines
Quoted 2 lines
the dev might be null, to be sure we move the dev assignation before the pci parent assignation.
This isn't worded strongly enough.
pcie->devwill absolutely be NULL at the point where it is assigned to pci.parent, which seem like a blatant bug and I don't know how this did ever work or if we just ignored the broken parent device connection.
This was broken by:
commit fd3be9d95f342a3d056a08a8e69fe81fd2a35948
Author: Sascha Hauer <[email protected]> Date: Tue Mar 26 11:07:37 2024 +0100
pci: add pci_controller_init()
Upcoming patches will add a list to struct pci_controller. To make sure we have a single point to initialize the list introduce a pci_controller_init() and call it from all drivers which use register_pci_controller(). Make sure host->parent is set correctly before calling register_pci_controller() as that will be needed for device tree parsing later.
Sascha
Signature · 4 lines
Pengutronix e.K. | | Steuerwalder Str. 21 | http://www.pengutronix.de/ | 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
Quoted 6 lines · Lucas Stach
Hi,
Am Mittwoch, dem 26.11.2025 um 22:40 -0500 schrieb [email protected]:
Quoted 2 lines
From: Chali Anis <[email protected]>
Quoted 7 lines
Quoted 2 lines
the dev might be null, to be sure we move the dev assignation before the pci parent assignation.
This isn't worded strongly enough.
pcie->devwill absolutely be NULL at the point where it is assigned to pci.parent, which seem like a blatant bug and I don't know how this did ever work or if we just ignored the broken parent device connection.
Reworded to:
pci: pci-tegra: fix null pointer assignation.
By the time we set pcie->pci.parent pcie->dev is null. Initialize it before usage.
Sascha
Signature · 4 lines
Pengutronix e.K. | | Steuerwalder Str. 21 | http://www.pengutronix.de/ | 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
Sascha Hauer
AppliedQuoted 4 lines · On Wed, 26 Nov 2025 22:40:24 -0500, [email protected] wrote:
the dev might be null, to be sure we move the dev assignation before the pci parent assignation.
Applied, thanks!
[1/1] pci: pci-tegra: fix null pointer assignation.
https://git.pengutronix.de/cgit/barebox/commit/?id=7d544d38174d (link may not be stable)
Best regards,
Signature · 1 line
Sascha Hauer <[email protected]>