lantiq: make PCI driver more robust
authorMathias Kresin <dev@kresin.me>
Mon, 28 Jan 2019 21:26:28 +0000 (22:26 +0100)
committerMathias Kresin <dev@kresin.me>
Mon, 12 Apr 2021 21:37:51 +0000 (23:37 +0200)
Check for error during probe and release resources on errors.

Signed-off-by: Mathias Kresin <dev@kresin.me>
target/linux/lantiq/patches-5.10/0200-MIPS-lantiq-pci-check-return-codes.patch [new file with mode: 0644]
target/linux/lantiq/patches-5.4/0200-MIPS-lantiq-pci-check-return-codes.patch [new file with mode: 0644]

diff --git a/target/linux/lantiq/patches-5.10/0200-MIPS-lantiq-pci-check-return-codes.patch b/target/linux/lantiq/patches-5.10/0200-MIPS-lantiq-pci-check-return-codes.patch
new file mode 100644 (file)
index 0000000..26ca59a
--- /dev/null
@@ -0,0 +1,39 @@
+From 0b9567e59cbdb7bec4646278b5c5b3e770ea11f9 Mon Sep 17 00:00:00 2001
+From: Mathias Kresin <dev@kresin.me>
+Date: Mon, 28 Jan 2019 22:08:05 +0100
+Subject: [PATCH 1/6] MIPS: lantiq: pci: check return codes
+
+ltq_pci_startup() returns an error if something went wrong. Check and
+return the error instead of pretend everything is fine.
+
+Signed-off-by: Mathias Kresin <dev@kresin.me>
+---
+ arch/mips/pci/pci-lantiq.c | 5 ++++-
+ 1 file changed, 4 insertions(+), 1 deletion(-)
+
+diff --git a/arch/mips/pci/pci-lantiq.c b/arch/mips/pci/pci-lantiq.c
+index 1ca42f482130..9afca76a7b02 100644
+--- a/arch/mips/pci/pci-lantiq.c
++++ b/arch/mips/pci/pci-lantiq.c
+@@ -207,6 +207,7 @@ static int ltq_pci_startup(struct platform_device *pdev)
+ static int ltq_pci_probe(struct platform_device *pdev)
+ {
+       struct resource *res_cfg, *res_bridge;
++      int ret;
+       pci_clear_flags(PCI_PROBE_ONLY);
+@@ -220,7 +221,9 @@ static int ltq_pci_probe(struct platform_device *pdev)
+       if (IS_ERR(ltq_pci_mapped_cfg))
+               return PTR_ERR(ltq_pci_mapped_cfg);
+-      ltq_pci_startup(pdev);
++      ret = ltq_pci_startup(pdev);
++      if (ret < 0)
++              return ret;
+       pci_load_of_ranges(&pci_controller, pdev->dev.of_node);
+       register_pci_controller(&pci_controller);
+-- 
+2.17.1
+
diff --git a/target/linux/lantiq/patches-5.4/0200-MIPS-lantiq-pci-check-return-codes.patch b/target/linux/lantiq/patches-5.4/0200-MIPS-lantiq-pci-check-return-codes.patch
new file mode 100644 (file)
index 0000000..26ca59a
--- /dev/null
@@ -0,0 +1,39 @@
+From 0b9567e59cbdb7bec4646278b5c5b3e770ea11f9 Mon Sep 17 00:00:00 2001
+From: Mathias Kresin <dev@kresin.me>
+Date: Mon, 28 Jan 2019 22:08:05 +0100
+Subject: [PATCH 1/6] MIPS: lantiq: pci: check return codes
+
+ltq_pci_startup() returns an error if something went wrong. Check and
+return the error instead of pretend everything is fine.
+
+Signed-off-by: Mathias Kresin <dev@kresin.me>
+---
+ arch/mips/pci/pci-lantiq.c | 5 ++++-
+ 1 file changed, 4 insertions(+), 1 deletion(-)
+
+diff --git a/arch/mips/pci/pci-lantiq.c b/arch/mips/pci/pci-lantiq.c
+index 1ca42f482130..9afca76a7b02 100644
+--- a/arch/mips/pci/pci-lantiq.c
++++ b/arch/mips/pci/pci-lantiq.c
+@@ -207,6 +207,7 @@ static int ltq_pci_startup(struct platform_device *pdev)
+ static int ltq_pci_probe(struct platform_device *pdev)
+ {
+       struct resource *res_cfg, *res_bridge;
++      int ret;
+       pci_clear_flags(PCI_PROBE_ONLY);
+@@ -220,7 +221,9 @@ static int ltq_pci_probe(struct platform_device *pdev)
+       if (IS_ERR(ltq_pci_mapped_cfg))
+               return PTR_ERR(ltq_pci_mapped_cfg);
+-      ltq_pci_startup(pdev);
++      ret = ltq_pci_startup(pdev);
++      if (ret < 0)
++              return ret;
+       pci_load_of_ranges(&pci_controller, pdev->dev.of_node);
+       register_pci_controller(&pci_controller);
+-- 
+2.17.1
+