Skip to contentSkip to conversation

misc: atmel_tclib: fix error return code in tc_probe()

PATCH In review Gustavo A. R. Silva 2 participants 2 messages Aug 9, 2017

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

PATCH 1/1 misc: atmel_tclib: fix error return code in tc_probe()

platform_get_irq() returns an error code, but the atmel_tclib driver ignores it and always returns -EINVAL. This is not correct and, prevents -EPROBE_DEFER from being propagated properly.

Print error message and propagate the return value of platform_get_irq on failure.

This issue was detected with the help of Coccinelle.

---
 drivers/misc/atmel_tclib.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/misc/atmel_tclib.c +4 -2
index ac24a4b..c5d3449 100644
@@ -112,8 +112,10 @@ static int __init tc_probe(struct platform_device *pdev)
 	unsigned int	i;
 
 	irq = platform_get_irq(pdev, 0);
-	if (irq < 0)
-		return -EINVAL;
+	if (irq < 0) {
+		dev_err(&pdev->dev, "Failed to get IRQ: %d\n", irq);
+		return irq;
+	}
 
 	tc = devm_kzalloc(&pdev->dev, sizeof(struct atmel_tc), GFP_KERNEL);
 	if (!tc)
Signature · 1 line
2.5.0
#1 lore raw
Quoted 4 lines · Gustavo A. R. Silva

platform_get_irq() returns an error code, but the atmel_tclib driver ignores it and always returns -EINVAL. This is not correct and, prevents -EPROBE_DEFER from being propagated properly.

Which will never happen because the kernel would not reach that point if the irqchip driver was not present. I would really love people to stop littering perfectly working drivers with unused error strings.

Quoted 35 lines

Print error message and propagate the return value of platform_get_irq on failure.

This issue was detected with the help of Coccinelle.

---
 drivers/misc/atmel_tclib.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/misc/atmel_tclib.c +4 -2
index ac24a4b..c5d3449 100644
@@ -112,8 +112,10 @@ static int __init tc_probe(struct platform_device *pdev)
 	unsigned int	i;
 
 	irq = platform_get_irq(pdev, 0);
-	if (irq < 0)
-		return -EINVAL;
+	if (irq < 0) {
+		dev_err(&pdev->dev, "Failed to get IRQ: %d\n", irq);
+		return irq;
+	}
 
 	tc = devm_kzalloc(&pdev->dev, sizeof(struct atmel_tc), GFP_KERNEL);
 	if (!tc)
Signature · 7 lines
2.5.0


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel at lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Signature · 3 lines
Alexandre Belloni, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com