Skip to contentSkip to conversation

PCI: exynos: fix the potential null pointer dereference

PATCH New Jaehoon Chung 3 participants 3 messages Jan 22, 2018 – Jan 29, 2018 1 message not in the archive

Subsystems (2)
lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): CGME20180122022856epcas1p494a9efeae478b299e3e8006adad71e6a@epcas1p4.samsung.com

#1 lore raw

PATCH 1/1 PCI: exynos: fix the potential null pointer dereference

Before calling the callback function, it needs to check whether init_clk_resources is assigned or not.
Otherwise, it can be occurred the NULL pointer dereference when init_clk_resources is not assigned.

Even though init_clk_resources is assigned now, it needs to prevent the potential NULL pointer dereference in future.

---
 drivers/pci/dwc/pci-exynos.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/pci/dwc/pci-exynos.c +2 -1
index 56f32aeebd0a..39f08881f9a4 100644
@@ -499,7 +499,8 @@ static int __init exynos_pcie_probe(struct platform_device *pdev)
 			return ret;
 	}
 
-	if (ep->ops && ep->ops->get_clk_resources) {
+	if (ep->ops && ep->ops->get_clk_resources &&
+			ep->ops->init_clk_resources) {
 		ret = ep->ops->get_clk_resources(ep);
 		if (ret)
 			return ret;
Signature · 1 line
2.15.1
#2 lore raw

PATCH 1/1 PCI: exynos: fix the potential null pointer dereference

Quoted 10 lines · Jaehoon Chung

Before calling the callback function, it needs to check whether init_clk_resources is assigned or not.
Otherwise, it can be occurred the NULL pointer dereference when init_clk_resources is not assigned.

Even though init_clk_resources is assigned now, it needs to prevent the potential NULL pointer dereference in future.

Best regards,
Jingoo Han

Quoted 21 lines
---
 drivers/pci/dwc/pci-exynos.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/pci/dwc/pci-exynos.c +2 -1
index 56f32aeebd0a..39f08881f9a4 100644
@@ -499,7 +499,8 @@ static int __init exynos_pcie_probe(struct
 platform_device *pdev)
 			return ret;
 	}
 
-	if (ep->ops && ep->ops->get_clk_resources) {
+	if (ep->ops && ep->ops->get_clk_resources &&
+			ep->ops->init_clk_resources) {
 		ret = ep->ops->get_clk_resources(ep);
 		if (ret)

return ret;
--
2.15.1

#3 lore raw

PATCH 1/1 PCI: exynos: fix the potential null pointer dereference

In reply to Jaehoon Chung
Quoted 29 lines · Jaehoon Chung

Before calling the callback function, it needs to check whether init_clk_resources is assigned or not.
Otherwise, it can be occurred the NULL pointer dereference when init_clk_resources is not assigned.

Even though init_clk_resources is assigned now, it needs to prevent the potential NULL pointer dereference in future.

---
 drivers/pci/dwc/pci-exynos.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/pci/dwc/pci-exynos.c +2 -1
index 56f32aeebd0a..39f08881f9a4 100644
@@ -499,7 +499,8 @@ static int __init exynos_pcie_probe(struct platform_device *pdev)
 			return ret;
 	}
 
-	if (ep->ops && ep->ops->get_clk_resources) {
+	if (ep->ops && ep->ops->get_clk_resources &&
+			ep->ops->init_clk_resources) {
 		ret = ep->ops->get_clk_resources(ep);
 		if (ret)
 			return ret;
Signature · 1 line
2.15.1

I applied it to pci/dwc for 4.16.

Thanks,
Lorenzo