Skip to contentSkip to conversation

staging: mfd: hi6421-spmi-pmic: Fix error return in hi6421_spmi_pmic_probe()

PATCH In review Jing Xiangfeng 2 participants 2 messages Sep 29, 2020 Staging

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 staging: mfd: hi6421-spmi-pmic: Fix error return in hi6421_spmi_pmic_probe()

Fix to return error code -ENOMEM from the error handling case instead of 0.

---
 drivers/staging/hikey9xx/hi6421-spmi-pmic.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/staging/hikey9xx/hi6421-spmi-pmic.c +3 -1
index 64b30d263c8d..4f34a5282970 100644
@@ -262,8 +262,10 @@ static int hi6421_spmi_pmic_probe(struct spmi_device *pdev)
 	hi6421_spmi_pmic_irq_prc(pmic);
 
 	pmic->irqs = devm_kzalloc(dev, HISI_IRQ_NUM * sizeof(int), GFP_KERNEL);
-	if (!pmic->irqs)
+	if (!pmic->irqs) {
+		ret = -ENOMEM;
 		goto irq_malloc;
+	}
 
 	pmic->domain = irq_domain_add_simple(np, HISI_IRQ_NUM, 0,
 					     &hi6421_spmi_domain_ops, pmic);
Signature · 1 line
2.26.0.106.g9fadedd
#1 lore raw
Quoted 13 lines · Jing Xiangfeng

Fix to return error code -ENOMEM from the error handling case instead of 0.

---
 drivers/staging/hikey9xx/hi6421-spmi-pmic.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/staging/hikey9xx/hi6421-spmi-pmic.c +0 -0
index 64b30d263c8d..4f34a5282970 100644

drivers/staging/hikey9xx/hi6421-spmi-pmic.c static int hi6421_spmi_pmic_probe(struct spmi_device *pdev) · line 267

Quoted 7 lines
drivers/staging/hikey9xx/hi6421-spmi-pmic.c +2 -1
@@ -262,8 +262,10 @@ static int hi6421_spmi_pmic_probe(struct spmi_device *pdev)
 	hi6421_spmi_pmic_irq_prc(pmic);
 
 	pmic->irqs = devm_kzalloc(dev, HISI_IRQ_NUM * sizeof(int), GFP_KERNEL);
-	if (!pmic->irqs)
+	if (!pmic->irqs) {
+		ret = -ENOMEM;
 		goto irq_malloc;

It shouldn't do a goto, it should just return directly. The goto releases an IRQ which isn't acquired until later in the function.

regards,
dan carpenter