Skip to contentSkip to conversation

pci: layerscape: Change to allocate zeroed memery for struct ls_pcie

PATCH New Zhiqiang Hou 2 participants 2 messages Mar 11, 2021 – Mar 16, 2021 PCI

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 pci: layerscape: Change to allocate zeroed memery for struct ls_pcie

From: Hou Zhiqiang <[email protected]>

As on some incipient Layerscape platforms (LS1043A series) there isn't separate PF control register block, these registers reside in the LUT register block, so when the driver detected there isn't 'ctrl', it will assign the 'lut' address to the ls_pcie->ctrl.

The current code allocate memory for the struct ls_pcie with random contents, this can result in skipping to assign the ls_pcie->ctrl with the 'lut' address, then further crash with the incorrect address.

Fixes 118e58e26eba ("pci: layerscape: Split the EP and RC driver")
---
 drivers/pci/pcie_layerscape_ep.c | 2 +-
 drivers/pci/pcie_layerscape_rc.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
drivers/pci/pcie_layerscape_ep.c +1 -1
index 14983cce4f..c7231635e4 100644
@@ -244,7 +244,7 @@ static int ls_pcie_ep_probe(struct udevice *dev)
 	int ret;
 	u32 svr;
 
-	pcie = devm_kmalloc(dev, sizeof(*pcie), GFP_KERNEL);
+	pcie = devm_kzalloc(dev, sizeof(*pcie), GFP_KERNEL);
 	if (!pcie)
 		return -ENOMEM;
 
drivers/pci/pcie_layerscape_rc.c +1 -1
index b055ed5165..bd2c19f7f0 100644
@@ -254,7 +254,7 @@ static int ls_pcie_probe(struct udevice *dev)
 
 	pcie_rc->bus = dev;
 
-	pcie = devm_kmalloc(dev, sizeof(*pcie), GFP_KERNEL);
+	pcie = devm_kzalloc(dev, sizeof(*pcie), GFP_KERNEL);
 	if (!pcie)
 		return -ENOMEM;
 
Signature · 1 line
2.17.1
#1 lore raw

PATCH 1/1 pci: layerscape: Change to allocate zeroed memery for struct ls_pcie

Quoted 7 lines · Zhiqiang Hou

From: Hou Zhiqiang <[email protected]>

As on some incipient Layerscape platforms (LS1043A series) there isn't separate PF control register block, these registers reside in the LUT register block, so when the driver detected there isn't 'ctrl', it will assign the 'lut' address to the ls_pcie->ctrl.

Quoted 7 lines

The current code allocate memory for the struct ls_pcie with random contents, this can result in skipping to assign the ls_pcie->ctrl with the 'lut' address, then further crash with the incorrect address.

Fixes 118e58e26eba ("pci: layerscape: Split the EP and RC driver")

---