mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH] pci: pci-tegra: fix null pointer assignation.
@ 2025-11-27  3:40 chalianis1
  2025-11-27  9:19 ` Lucas Stach
  2025-11-27 11:53 ` Sascha Hauer
  0 siblings, 2 replies; 5+ messages in thread
From: chalianis1 @ 2025-11-27  3:40 UTC (permalink / raw)
  To: s.hauer; +Cc: barebox, Chali Anis

From: Chali Anis <chalianis1@gmail.com>

the dev might be null, to be sure we move the dev assignation before
the pci parent assignation.

Signed-off-by: Chali Anis <chalianis1@gmail.com>
---
 drivers/pci/pci-tegra.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/pci/pci-tegra.c b/drivers/pci/pci-tegra.c
index b7f8297d153e..dabe63500a4a 100644
--- a/drivers/pci/pci-tegra.c
+++ b/drivers/pci/pci-tegra.c
@@ -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) {



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] pci: pci-tegra: fix null pointer assignation.
  2025-11-27  3:40 [PATCH] pci: pci-tegra: fix null pointer assignation chalianis1
@ 2025-11-27  9:19 ` Lucas Stach
  2025-11-27 11:53   ` Sascha Hauer
  2025-11-27 11:54   ` Sascha Hauer
  2025-11-27 11:53 ` Sascha Hauer
  1 sibling, 2 replies; 5+ messages in thread
From: Lucas Stach @ 2025-11-27  9:19 UTC (permalink / raw)
  To: chalianis1, s.hauer; +Cc: barebox

Hi,

Am Mittwoch, dem 26.11.2025 um 22:40 -0500 schrieb
chalianis1@gmail.com:
> From: Chali Anis <chalianis1@gmail.com>
> 
> 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

> 
> Signed-off-by: Chali Anis <chalianis1@gmail.com>
> ---
>  drivers/pci/pci-tegra.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/pci/pci-tegra.c b/drivers/pci/pci-tegra.c
> index b7f8297d153e..dabe63500a4a 100644
> --- a/drivers/pci/pci-tegra.c
> +++ b/drivers/pci/pci-tegra.c
> @@ -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) {
> 




^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] pci: pci-tegra: fix null pointer assignation.
  2025-11-27  9:19 ` Lucas Stach
@ 2025-11-27 11:53   ` Sascha Hauer
  2025-11-27 11:54   ` Sascha Hauer
  1 sibling, 0 replies; 5+ messages in thread
From: Sascha Hauer @ 2025-11-27 11:53 UTC (permalink / raw)
  To: Lucas Stach; +Cc: chalianis1, barebox

On Thu, Nov 27, 2025 at 10:19:34AM +0100, Lucas Stach wrote:
> Hi,
> 
> Am Mittwoch, dem 26.11.2025 um 22:40 -0500 schrieb
> chalianis1@gmail.com:
> > From: Chali Anis <chalianis1@gmail.com>
> > 
> > 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.

This was broken by:

commit fd3be9d95f342a3d056a08a8e69fe81fd2a35948
Author: Sascha Hauer <s.hauer@pengutronix.de>
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.

    Link: https://lore.barebox.org/20240326100746.471532-8-s.hauer@pengutronix.de
    Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>

Sascha

-- 
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 |



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] pci: pci-tegra: fix null pointer assignation.
  2025-11-27  3:40 [PATCH] pci: pci-tegra: fix null pointer assignation chalianis1
  2025-11-27  9:19 ` Lucas Stach
@ 2025-11-27 11:53 ` Sascha Hauer
  1 sibling, 0 replies; 5+ messages in thread
From: Sascha Hauer @ 2025-11-27 11:53 UTC (permalink / raw)
  To: chalianis1; +Cc: barebox


On Wed, 26 Nov 2025 22:40:24 -0500, chalianis1@gmail.com 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,
-- 
Sascha Hauer <s.hauer@pengutronix.de>




^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] pci: pci-tegra: fix null pointer assignation.
  2025-11-27  9:19 ` Lucas Stach
  2025-11-27 11:53   ` Sascha Hauer
@ 2025-11-27 11:54   ` Sascha Hauer
  1 sibling, 0 replies; 5+ messages in thread
From: Sascha Hauer @ 2025-11-27 11:54 UTC (permalink / raw)
  To: Lucas Stach; +Cc: chalianis1, barebox

On Thu, Nov 27, 2025 at 10:19:34AM +0100, Lucas Stach wrote:
> Hi,
> 
> Am Mittwoch, dem 26.11.2025 um 22:40 -0500 schrieb
> chalianis1@gmail.com:
> > From: Chali Anis <chalianis1@gmail.com>
> > 
> > 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.

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.

Fixes: fd3be9d95f34 ("pci: add pci_controller_init()")

Sascha

-- 
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 |



^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2025-11-27 11:55 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-11-27  3:40 [PATCH] pci: pci-tegra: fix null pointer assignation chalianis1
2025-11-27  9:19 ` Lucas Stach
2025-11-27 11:53   ` Sascha Hauer
2025-11-27 11:54   ` Sascha Hauer
2025-11-27 11:53 ` Sascha Hauer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox