diff options
author | Bjorn Helgaas <bhelgaas@google.com> | 2022-01-27 22:49:49 +0100 |
---|---|---|
committer | Bjorn Helgaas <bhelgaas@google.com> | 2022-02-01 18:13:52 +0100 |
commit | 053ca37c87af65f41f5842070c68aa53c3d035f5 (patch) | |
tree | 2130c0dc76fc9b4ad56ac026786653e04c87ab30 /LICENSES | |
parent | Linux 5.17-rc1 (diff) | |
download | linux-053ca37c87af65f41f5842070c68aa53c3d035f5.tar.xz linux-053ca37c87af65f41f5842070c68aa53c3d035f5.zip |
PCI: j721e: Initialize pcie->cdns_pcie before using it
Christian reported a NULL pointer dereference in j721e_pcie_probe() caused
by 19e863828acf ("PCI: j721e: Drop redundant struct device *"), which
removed struct j721e_pcie.dev since there's another copy in struct
cdns_pcie.dev reachable via j721e_pcie->cdns_pcie->dev.
The problem is that j721e_pcie->cdns_pcie was dereferenced before being
initialized:
j721e_pcie_probe
pcie = devm_kzalloc() # struct j721e_pcie
j721e_pcie_ctrl_init(pcie)
dev = pcie->cdns_pcie->dev <-- dereference cdns_pcie
switch (mode) {
case PCI_MODE_RC:
cdns_pcie = ... # alloc as part of pci_host_bridge
pcie->cdns_pcie = cdns_pcie <-- initialize pcie->cdns_pcie
Move the cdns_pcie initialization earlier so it is done before it is used.
This also simplifies the error exits.
Fixes: 19e863828acf ("PCI: j721e: Drop redundant struct device *")
Link: https://lore.kernel.org/r/20220127222951.GA144828@bhelgaas
Link: https://lore.kernel.org/r/20220124122132.435743-1-christian.gmeiner@gmail.com
Reported-by: Christian Gmeiner <christian.gmeiner@gmail.com>
Tested-by: Christian Gmeiner <christian.gmeiner@gmail.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Diffstat (limited to 'LICENSES')
0 files changed, 0 insertions, 0 deletions