U-Boot Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] fdt: off by one in ofnode_lookup_fdt()
@ 2023-07-26  6:59 Dan Carpenter
  2023-07-27  0:49 ` Simon Glass
  2023-08-09  1:40 ` Tom Rini
  0 siblings, 2 replies; 3+ messages in thread
From: Dan Carpenter @ 2023-07-26  6:59 UTC (permalink / raw)
  To: Simon Glass; +Cc: u-boot

The "oftree_count" is the number of entries which have been set in
the oftree_list[] array.  If all the entries have been initialized then
this off by one would result in reading one element beyond the end
of the array.

Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
---
 drivers/core/ofnode.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/core/ofnode.c b/drivers/core/ofnode.c
index 8df16e56af5c..a4dc9bde085c 100644
--- a/drivers/core/ofnode.c
+++ b/drivers/core/ofnode.c
@@ -103,7 +103,7 @@ void *ofnode_lookup_fdt(ofnode node)
 	if (gd->flags & GD_FLG_RELOC) {
 		uint i = OFTREE_TREE_ID(node.of_offset);
 
-		if (i > oftree_count) {
+		if (i >= oftree_count) {
 			log_debug("Invalid tree ID %x\n", i);
 			return NULL;
 		}
-- 
2.39.2


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

* Re: [PATCH] fdt: off by one in ofnode_lookup_fdt()
  2023-07-26  6:59 [PATCH] fdt: off by one in ofnode_lookup_fdt() Dan Carpenter
@ 2023-07-27  0:49 ` Simon Glass
  2023-08-09  1:40 ` Tom Rini
  1 sibling, 0 replies; 3+ messages in thread
From: Simon Glass @ 2023-07-27  0:49 UTC (permalink / raw)
  To: Dan Carpenter; +Cc: u-boot

Hi Dan,

On Wed, 26 Jul 2023 at 00:59, Dan Carpenter <dan.carpenter@linaro.org> wrote:
>
> The "oftree_count" is the number of entries which have been set in
> the oftree_list[] array.  If all the entries have been initialized then
> this off by one would result in reading one element beyond the end
> of the array.
>
> Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
> ---
>  drivers/core/ofnode.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

Reviewed-by: Simon Glass <sjg@chromium.org>

Thanks. It can be helpful to add 'Fixes:' tags on such patches.

>
> diff --git a/drivers/core/ofnode.c b/drivers/core/ofnode.c
> index 8df16e56af5c..a4dc9bde085c 100644
> --- a/drivers/core/ofnode.c
> +++ b/drivers/core/ofnode.c
> @@ -103,7 +103,7 @@ void *ofnode_lookup_fdt(ofnode node)
>         if (gd->flags & GD_FLG_RELOC) {
>                 uint i = OFTREE_TREE_ID(node.of_offset);
>
> -               if (i > oftree_count) {
> +               if (i >= oftree_count) {
>                         log_debug("Invalid tree ID %x\n", i);
>                         return NULL;
>                 }
> --
> 2.39.2
>

Regards,
Simon

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

* Re: [PATCH] fdt: off by one in ofnode_lookup_fdt()
  2023-07-26  6:59 [PATCH] fdt: off by one in ofnode_lookup_fdt() Dan Carpenter
  2023-07-27  0:49 ` Simon Glass
@ 2023-08-09  1:40 ` Tom Rini
  1 sibling, 0 replies; 3+ messages in thread
From: Tom Rini @ 2023-08-09  1:40 UTC (permalink / raw)
  To: Dan Carpenter; +Cc: Simon Glass, u-boot

[-- Attachment #1: Type: text/plain, Size: 455 bytes --]

On Wed, Jul 26, 2023 at 09:59:52AM +0300, Dan Carpenter wrote:

> The "oftree_count" is the number of entries which have been set in
> the oftree_list[] array.  If all the entries have been initialized then
> this off by one would result in reading one element beyond the end
> of the array.
> 
> Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
> Reviewed-by: Simon Glass <sjg@chromium.org>

Applied to u-boot/next, thanks!

-- 
Tom

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 659 bytes --]

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

end of thread, other threads:[~2023-08-09  1:41 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-07-26  6:59 [PATCH] fdt: off by one in ofnode_lookup_fdt() Dan Carpenter
2023-07-27  0:49 ` Simon Glass
2023-08-09  1:40 ` Tom Rini

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox