[PATCH master 2/2] hab: habv4: warn if more than 10 HAB events are found

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]


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@xxxxxxxxxx>
Signed-off-by: Ahmad Fatoum <a.fatoum@xxxxxxxxxxxxxx>
 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,
 			events[num_events] = search;
-			num_events++;
+			if (num_events < ARRAY_SIZE(events))
+				num_events++;
+			else
+				pr_warn("Discarding excess event\n");
 		} else {

[Index of Archives]     [Linux Embedded]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux