[PATCH master 2/2] hab: habv4: warn if more than 10 HAB events are found
Ahmad Fatoum
a.fatoum at pengutronix.de
Thu Jan 11 04:12:19 PST 2024
The function has space for up to 10 HAB events. On the off-chance that
there are more found, it will scribble them over stack memory.
Fix this by only collecting up to 10 events and printing a warning if
that's exceeded. Once we have reports that this issue manifests, we can
consider extending the array or dynamically allocating it.
Reported-by: Christian Melki <christian.melki at t2data.com>
Signed-off-by: Ahmad Fatoum <a.fatoum at pengutronix.de>
---
drivers/hab/habv4.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/drivers/hab/habv4.c b/drivers/hab/habv4.c
index 4db1e7cc0f3a..66caa875835d 100644
--- a/drivers/hab/habv4.c
+++ b/drivers/hab/habv4.c
@@ -255,7 +255,10 @@ static enum hab_status imx8m_read_sram_events(enum hab_status status,
break;
events[num_events] = search;
- num_events++;
+ if (num_events < ARRAY_SIZE(events))
+ num_events++;
+ else
+ pr_warn("Discarding excess event\n");
} else {
sram++;
}
--
2.39.2
More information about the barebox
mailing list