Skip to contentSkip to conversation

irq-imx-gpcv2: Adjustments for imx_gpcv2_irqchip_init()

PATCH New SF Markus Elfring 1 participant 4 messages Jan 18, 2018

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

cover irq-imx-gpcv2: Adjustments for imx_gpcv2_irqchip_init()

From: Markus Elfring <[email protected]>
Date: Thu, 18 Jan 2018 22:08:44 +0100

Three update suggestions were taken into account
from static source code analysis.

Markus Elfring (3):
Delete an error message for a failed memory allocation Improve a size determination
Use common error handling code

 drivers/irqchip/irq-imx-gpcv2.c | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)
Signature · 1 line
2.15.1
#1 lore raw

PATCH 1/3 irq-imx-gpcv2: Delete an error message for a failed memory allocation in imx_gpcv2_irqchip_init()

From: Markus Elfring <[email protected]>
Date: Thu, 18 Jan 2018 21:23:06 +0100

Omit an extra message for a memory allocation failure in this function.

This issue was detected by using the Coccinelle software.

---
 drivers/irqchip/irq-imx-gpcv2.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/irqchip/irq-imx-gpcv2.c +1 -3
index 675eda5ff2b8..f08fcbb46b1b 100644
@@ -225,10 +225,8 @@ static int __init imx_gpcv2_irqchip_init(struct device_node *node,
 	}
 
 	cd = kzalloc(sizeof(struct gpcv2_irqchip_data), GFP_KERNEL);
-	if (!cd) {
-		pr_err("kzalloc failed!\n");
+	if (!cd)
 		return -ENOMEM;
-	}
 
 	raw_spin_lock_init(&cd->rlock);
 
Signature · 1 line
2.15.1
#2 lore raw

PATCH 2/3 irq-imx-gpcv2: Improve a size determination in imx_gpcv2_irqchip_init()

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Thu, 18 Jan 2018 21:25:13 +0100

Replace the specification of a data structure by a pointer dereference as the parameter for the operator "sizeof" to make the corresponding size determination a bit safer according to the Linux coding style convention.

This issue was detected by using the Coccinelle software.

---
 drivers/irqchip/irq-imx-gpcv2.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/irqchip/irq-imx-gpcv2.c +1 -1
index f08fcbb46b1b..e62f22c84112 100644
@@ -224,7 +224,7 @@ static int __init imx_gpcv2_irqchip_init(struct device_node *node,
 		return -ENXIO;
 	}
 
-	cd = kzalloc(sizeof(struct gpcv2_irqchip_data), GFP_KERNEL);
+	cd = kzalloc(sizeof(*cd), GFP_KERNEL);
 	if (!cd)
 		return -ENOMEM;
 
Signature · 1 line
2.15.1
#3 lore raw

PATCH 3/3 irq-imx-gpcv2: Use common error handling code in imx_gpcv2_irqchip_init()

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Thu, 18 Jan 2018 22:00:05 +0100

Add a jump target so that a bit of exception handling can be better reused at the end of this function.

---
 drivers/irqchip/irq-imx-gpcv2.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)
drivers/irqchip/irq-imx-gpcv2.c +6 -4
index e62f22c84112..2dc348581877 100644
@@ -233,16 +233,14 @@ static int __init imx_gpcv2_irqchip_init(struct device_node *node,
 	cd->gpc_base = of_iomap(node, 0);
 	if (!cd->gpc_base) {
 		pr_err("fsl-gpcv2: unable to map gpc registers\n");
-		kfree(cd);
-		return -ENOMEM;
+		goto free_data;
 	}
 
 	domain = irq_domain_add_hierarchy(parent_domain, 0, GPC_MAX_IRQS,
 				node, &gpcv2_irqchip_data_domain_ops, cd);
 	if (!domain) {
 		iounmap(cd->gpc_base);
-		kfree(cd);
-		return -ENOMEM;
+		goto free_data;
 	}
 	irq_set_default_host(domain);
 
@@ -272,6 +270,10 @@ static int __init imx_gpcv2_irqchip_init(struct device_node *node,
 	 */
 	of_node_clear_flag(node, OF_POPULATED);
 	return 0;
+
+free_data:
+	kfree(cd);
+	return -ENOMEM;
 }
 
 IRQCHIP_DECLARE(imx_gpcv2, "fsl,imx7d-gpc", imx_gpcv2_irqchip_init);
Signature · 1 line
2.15.1