On Sun, Sep 18, 2022 at 10:45:41AM +0000, Klemens Nanni wrote:
> On Sun, Sep 18, 2022 at 12:13:34PM +0200, Martin Pieuchot wrote:
> > The rockpro64 no longer boots in multi-user on -current.  It hangs after
> > displaying the following lines:
> > 
> > rkiis0 at mainbus0
> > rkiis1 at mainbus0
> > 
> > The 8/09 snapshot works, the next one from 11/09 doesn't.
> 
> Smells like a similar hang in 'rkvop0 at ...' I see on the Pinebook Pro.
> 
> Reverting this sys/dev/ofw/fdt.c fixed it (I mailed them already):
> 
>       revision 1.31
>       date: 2022/09/11 08:33:03;  author: kettenis;  state: Exp;  lines: +21 
> -4;
>       Change OF_getnodebyname() such that lokking up a node using just the 
> name
>       without a unit number (so without the @1234 bit) works as well.
> 
>       ok patrick@, gkoehler@
> 
> > 
> > bsd.rd still boots.
> 
> Same on Pinebook Pro.

Found the issue, see inline.

> commit a4fa68764dee46c3d376031e17913b52c65045a0
> Author: kettenis <[email protected]>
> Date:   Sun Sep 11 08:33:03 2022 +0000
> 
>     Change OF_getnodebyname() such that lokking up a node using just the name
>     without a unit number (so without the @1234 bit) works as well.
>     
>     ok patrick@, gkoehler@
> 
> diff --git a/sys/dev/ofw/fdt.c b/sys/dev/ofw/fdt.c
> index 9de907d6693..834c83ad55d 100644
> --- a/sys/dev/ofw/fdt.c
> +++ b/sys/dev/ofw/fdt.c
> @@ -1,4 +1,4 @@
> -/*   $OpenBSD: fdt.c,v 1.30 2022/08/21 12:52:10 jasper Exp $ */
> +/*   $OpenBSD: fdt.c,v 1.31 2022/09/11 08:33:03 kettenis Exp $       */
>  
>  /*
>   * Copyright (c) 2009 Dariusz Swiderski <[email protected]>
> @@ -882,16 +882,33 @@ int
>  OF_getnodebyname(int handle, const char *name)
>  {
>       void *node = (char *)tree.header + handle;
> +     void *child;
> +     char *data;
> +     int len;
>  
>       if (handle == 0)
>               node = fdt_find_node("/");
>  
> -     for (node = fdt_child_node(node); node; node = fdt_next_node(node)) {
> -             if (strcmp(name, fdt_node_name(node)) == 0)
> +     for (child = fdt_child_node(node); child;
> +          child = fdt_next_node(child)) {
> +             if (strcmp(name, fdt_node_name(child)) == 0)
>                       break;
>       }
> +     if (child)
> +             return (char *)child - (char *)tree.header;
> +
> +     len = strlen(name);
> +     for (child = fdt_child_node(node); child;
> +          child = fdt_next_node(node)) {

The call to fdt_next_node() needs to happen on child instead of node,
otherwise this will become an endless loop.

> +             data = fdt_node_name(child);
> +             if (strncmp(name, data, len) == 0 &&
> +                 strlen(data) > len && data[len] == '@')
> +                     break;
> +     }
> +     if (child)
> +             return (char *)child - (char *)tree.header;
>  
> -     return node ? ((char *)node - (char *)tree.header) : 0;
> +     return 0;
>  }
>  
>  int

Reply via email to