diff mbox series

arm: match-footbridge: Add error handling in dc21285_setup()

Message ID 20230923160353.42915-1-liuhaoran14@163.com (mailing list archive)
State New, archived
Headers show
Series arm: match-footbridge: Add error handling in dc21285_setup() | expand

Commit Message

Haoran Liu Sept. 23, 2023, 4:03 p.m. UTC
This patch adds error-handling for the allocate_resource()
inside the dc21285_setup().

Signed-off-by: liuhaoran <liuhaoran14@163.com>
---
 arch/arm/mach-footbridge/dc21285.c | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/arch/arm/mach-footbridge/dc21285.c b/arch/arm/mach-footbridge/dc21285.c
index f8920d0010de..1970c66eb964 100644
--- a/arch/arm/mach-footbridge/dc21285.c
+++ b/arch/arm/mach-footbridge/dc21285.c
@@ -261,6 +261,7 @@  static struct notifier_block dc21285_pci_bus_nb = {
 int __init dc21285_setup(int nr, struct pci_sys_data *sys)
 {
 	struct resource *res;
+	int error;
 
 	res = kcalloc(2, sizeof(struct resource), GFP_KERNEL);
 	if (!res) {
@@ -273,10 +274,21 @@  int __init dc21285_setup(int nr, struct pci_sys_data *sys)
 	res[1].flags = IORESOURCE_MEM | IORESOURCE_PREFETCH;
 	res[1].name  = "Footbridge prefetch";
 
-	allocate_resource(&iomem_resource, &res[1], 0x20000000,
+	error = allocate_resource(&iomem_resource, &res[1], 0x20000000,
 			  0xa0000000, 0xffffffff, 0x20000000, NULL, NULL);
+	if (error < 0) {
+		printk(KERN_ERR "%s: allocate_resource failed %d!"
+		       , __func__, error);
+		return 0;
+	}
+
 	allocate_resource(&iomem_resource, &res[0], 0x40000000,
 			  0x80000000, 0xffffffff, 0x40000000, NULL, NULL);
+	if (error < 0) {
+		printk(KERN_ERR "%s: allocate_resource failed %d!"
+		       , __func__, error);
+		return 0;
+	}
 
 	sys->mem_offset  = DC21285_PCI_MEM;