[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <CAL_JsqLG9Mgndo4WCr8GRdkW3Hrs_U7XedSfjSMQGnsf2cPLmQ@mail.gmail.com>
Date: Thu, 25 Mar 2021 10:28:17 -0600
From: Rob Herring <robh+dt@...nel.org>
To: Changbin Du <changbin.du@...il.com>
Cc: Frank Rowand <frowand.list@...il.com>, devicetree@...r.kernel.org,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH] of/fdt: Check dtb pointer first in unflatten_device_tree
On Thu, Mar 25, 2021 at 10:00 AM Changbin Du <changbin.du@...il.com> wrote:
>
> On Wed, Mar 24, 2021 at 10:52:30AM -0600, Rob Herring wrote:
> > On Wed, Mar 24, 2021 at 9:04 AM Changbin Du <changbin.du@...il.com> wrote:
> > >
> > > The setup_arch() would invoke unflatten_device_tree() even no
> > > valid fdt found. So we'd better check it first and return early.
> > >
> > > Signed-off-by: Changbin Du <changbin.du@...il.com>
> > > ---
> > > drivers/of/fdt.c | 5 +++++
> > > 1 file changed, 5 insertions(+)
> > >
> > > diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c
> > > index dcc1dd96911a..05d439d63bc5 100644
> > > --- a/drivers/of/fdt.c
> > > +++ b/drivers/of/fdt.c
> > > @@ -1225,6 +1225,11 @@ bool __init early_init_dt_scan(void *params)
> > > */
> > > void __init unflatten_device_tree(void)
> > > {
> > > + if (!initial_boot_params) {
> > > + pr_warn("No valid device tree found, continuing without\n");
> >
> > How are you going to see this message if you have no DT?
> >
> This aligns to what unflatten_and_copy_device_tree() does.
Humm, then we should have a single check that covers both cases. Or we
should remove that one.
>
> > > + return;
> >
> > And the arch is supposed to just continue on oblivious that it has no DT?
> >
> As checking the arch code(arm, riscv), I suppose so.
>
> > > + }
> > > +
> > > __unflatten_device_tree(initial_boot_params, NULL, &of_root,
> > > early_init_dt_alloc_memory_arch, false);
> >
> > Soon as you get here with a NULL initial_boot_params, you'll get a
> > backtrace and halt.
> >
> No, we have returned before.
I mean without your addition we'll get here with a NULL.
Rob
Powered by blists - more mailing lists