[PATCH] tools: gpio-hammer: Accept the maximum number of line offsets
From: Zhu Jun
Date: Fri Nov 20 2026 - 01:18:40 EST
The offset count is incremented for every -o option, but the final
check rejects the maximum itself and reports one extra offset. Only
reject counts above the maximum and report the actual count.
Fixes: d1ee7e1f5c91 ("tools: gpio-hammer: Avoid potential overflow in main")
Signed-off-by: Zhu Jun <zhujun2@xxxxxxxxxxxxxxxxxxxx>
---
tools/gpio/gpio-hammer.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/tools/gpio/gpio-hammer.c b/tools/gpio/gpio-hammer.c
index 1a21e5460242..df6f71e48c59 100644
--- a/tools/gpio/gpio-hammer.c
+++ b/tools/gpio/gpio-hammer.c
@@ -159,10 +159,10 @@ int main(int argc, char **argv)
}
}
- if (i >= GPIOHANDLES_MAX) {
+ if (i > GPIOHANDLES_MAX) {
fprintf(stderr,
"Only %d occurrences of '-o' are allowed, %d were found\n",
- GPIOHANDLES_MAX, i + 1);
+ GPIOHANDLES_MAX, i);
return -1;
}