Skip to contentSkip to conversation

genirq/timings: Fix error return code in irq_timings_test_irqs()

PATCH Superseded Zhen Lei 2 participants 3 messages May 8, 2021 – Aug 11, 2021 IRQ

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Zhen Lei

author
#0 lore raw

PATCH 1/1 genirq/timings: Fix error return code in irq_timings_test_irqs()

Fix to return a negative error code from the error handling case instead of 0, as done elsewhere in this function.

Fixes f52da98d900e ("genirq/timings: Add selftest for irqs circular buffer")
---
 kernel/irq/timings.c | 2 ++
 1 file changed, 2 insertions(+)
kernel/irq/timings.c +2 -0
index d309d6fbf5bd..12893be1199a 100644
@@ -794,12 +794,14 @@ static int __init irq_timings_test_irqs(struct timings_intervals *ti)
 
 		__irq_timings_store(irq, irqs, ti->intervals[i]);
 		if (irqs->circ_timings[i & IRQ_TIMINGS_MASK] != index) {
+			ret = -EFAULT;
 			pr_err("Failed to store in the circular buffer\n");
 			goto out;
 		}
 	}
 
 	if (irqs->count != ti->count) {
+		ret = -EFAULT;
 		pr_err("Count differs\n");
 		goto out;
 	}
Signature · 1 line
2.25.1
#1 lore raw
Quoted 2 lines · Zhen Lei

Fix to return a negative error code from the error handling case instead of 0, as done elsewhere in this function.

Returning an error code is fine, but

kernel/irq/timings.c static int __init irq_timings_test_irqs(struct timings_intervals *ti) · line 797

Quoted 4 lines
kernel/irq/timings.c +1 -0
 		__irq_timings_store(irq, irqs, ti->intervals[i]);
 		if (irqs->circ_timings[i & IRQ_TIMINGS_MASK] != index) {
+			ret = -EFAULT;

EFAULT is really not appropriate here. EFAULT is used for mapping faults. ENOSPC or EBADSLT perhaps?

kernel/irq/timings.c static int __init irq_timings_test_irqs(struct timings_intervals *ti) · line 804

Quoted 7 lines
kernel/irq/timings.c +1 -0
 			pr_err("Failed to store in the circular buffer\n");
 			goto out;
 		}
 	}
 
 	if (irqs->count != ti->count) {
+		ret = -EFAULT;

ERANGE?

Thanks,

tglx

#2 lore raw
Quoted 7 lines · Thomas Gleixner
Quoted 2 lines · Zhen Lei

Fix to return a negative error code from the error handling case instead of 0, as done elsewhere in this function.

Returning an error code is fine, but

Quoted 1 line
Quoted 6 lines

kernel/irq/timings.c static int __init irq_timings_test_irqs(struct timings_intervals *ti) · line 797

Quoted 3 lines
kernel/irq/timings.c +1 -0
 		__irq_timings_store(irq, irqs, ti->intervals[i]);
 		if (irqs->circ_timings[i & IRQ_TIMINGS_MASK] != index) {
+			ret = -EFAULT;

EFAULT is really not appropriate here. EFAULT is used for mapping faults. ENOSPC or EBADSLT perhaps?

EBADSLT will be better, the cyclic buffer can not be "no space".

Quoted 10 lines

kernel/irq/timings.c static int __init irq_timings_test_irqs(struct timings_intervals *ti) · line 804

Quoted 8 lines
kernel/irq/timings.c +1 -0
 			pr_err("Failed to store in the circular buffer\n");
 			goto out;
 		}
 	}
 
 	if (irqs->count != ti->count) {
+		ret = -EFAULT;

ERANGE?

Looks better than EFAULT.

Thank you for your suggestion, I will send v2.

Quoted 6 lines

Thanks,

tglx
.