devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Rob Herring <robh+dt@kernel.org>
To: Changbin Du <changbin.du@gmail.com>
Cc: Frank Rowand <frowand.list@gmail.com>,
	devicetree@vger.kernel.org,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] of/fdt: Check dtb pointer first in unflatten_device_tree
Date: Thu, 25 Mar 2021 10:28:17 -0600	[thread overview]
Message-ID: <CAL_JsqLG9Mgndo4WCr8GRdkW3Hrs_U7XedSfjSMQGnsf2cPLmQ@mail.gmail.com> (raw)
In-Reply-To: <20210325155954.iun4hdcegi4b3qm2@mail.google.com>

On Thu, Mar 25, 2021 at 10:00 AM Changbin Du <changbin.du@gmail.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@gmail.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@gmail.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

      reply	other threads:[~2021-03-25 16:29 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-24 15:04 [PATCH] of/fdt: Check dtb pointer first in unflatten_device_tree Changbin Du
2021-03-24 16:52 ` Rob Herring
2021-03-25 16:00   ` Changbin Du
2021-03-25 16:28     ` Rob Herring [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAL_JsqLG9Mgndo4WCr8GRdkW3Hrs_U7XedSfjSMQGnsf2cPLmQ@mail.gmail.com \
    --to=robh+dt@kernel.org \
    --cc=changbin.du@gmail.com \
    --cc=devicetree@vger.kernel.org \
    --cc=frowand.list@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).