linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] bus: stm32_firewall: fix off by one in stm32_firewall_get_firewall()
@ 2024-04-12  8:25 Dan Carpenter
  2024-04-12  8:52 ` Gatien CHEVALLIER
  2024-04-24 13:14 ` Alexandre TORGUE
  0 siblings, 2 replies; 3+ messages in thread
From: Dan Carpenter @ 2024-04-12  8:25 UTC (permalink / raw)
  To: Gatien Chevallier
  Cc: Maxime Coquelin, Alexandre Torgue, linux-stm32, linux-arm-kernel,
	linux-kernel, kernel-janitors

The "nb_firewall" variable is the number of elements in the firewall[]
array, which is allocated in stm32_firewall_populate_bus().  So change
this > comparison to >= to prevent an out of bound access.

Fixes: 5c9668cfc6d7 ("firewall: introduce stm32_firewall framework")
Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
---
 drivers/bus/stm32_firewall.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/bus/stm32_firewall.c b/drivers/bus/stm32_firewall.c
index decb79449047..2fc9761dadec 100644
--- a/drivers/bus/stm32_firewall.c
+++ b/drivers/bus/stm32_firewall.c
@@ -53,7 +53,7 @@ int stm32_firewall_get_firewall(struct device_node *np, struct stm32_firewall *f
 			return err;
 		}
 
-		if (j > nb_firewall) {
+		if (j >= nb_firewall) {
 			pr_err("Too many firewall controllers");
 			of_node_put(provider);
 			return -EINVAL;
-- 
2.43.0


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2024-04-24 13:15 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-04-12  8:25 [PATCH] bus: stm32_firewall: fix off by one in stm32_firewall_get_firewall() Dan Carpenter
2024-04-12  8:52 ` Gatien CHEVALLIER
2024-04-24 13:14 ` Alexandre TORGUE

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).