mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Michael Tretter <m.tretter@pengutronix.de>
To: barebox@lists.infradead.org
Cc: "Thomas Hämmerle" <Thomas.Haemmerle@wolfvision.net>,
	"Michael Tretter" <m.tretter@pengutronix.de>
Subject: [PATCH v2] blspec: skip entries that are not blspec entries
Date: Tue, 24 Sep 2019 10:01:52 +0200	[thread overview]
Message-ID: <20190924080152.7085-1-m.tretter@pengutronix.de> (raw)

The list of boot entries can contain items that are not blspec entries.
For example, the bootchooser also adds an item to this list. Therefore,
blspec cannot unconditionally interpret entries as blspec entries.

The error is reproduced by listing the boot entries with the bootchooser
and a rootfs with blspec entries, e.g.:

	boot -l bootchooser /mnt/nfs

Check if a bootentry is a blspec entry by testing if the boot function
is blspec_boot.

Reported-by: Thomas Hämmerle <Thomas.Haemmerle@wolfvision.net>
Signed-off-by: Michael Tretter <m.tretter@pengutronix.de>
---
Changelog:

v1->v2:
- fix compilation error
---
 common/blspec.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/common/blspec.c b/common/blspec.c
index 7c27e0b869..7fb62d310f 100644
--- a/common/blspec.c
+++ b/common/blspec.c
@@ -306,6 +306,14 @@ static struct blspec_entry *blspec_entry_open(struct bootentries *bootentries,
 	return entry;
 }
 
+/*
+ * is_blspec_entry - check if a bootentry is a blspec entry
+ */
+static inline bool is_blspec_entry(struct bootentry *entry)
+{
+	return entry->boot == blspec_boot;
+}
+
 /*
  * blspec_have_entry - check if we already have an entry with
  *                     a certain path
@@ -316,6 +324,8 @@ static int blspec_have_entry(struct bootentries *bootentries, const char *path)
 	struct blspec_entry *e;
 
 	list_for_each_entry(be, &bootentries->entries, list) {
+		if (!is_blspec_entry(be))
+			continue;
 		e = container_of(be, struct blspec_entry, entry);
 		if (e->configpath && !strcmp(e->configpath, path))
 			return 1;
-- 
2.20.1


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

                 reply	other threads:[~2019-09-24  8:02 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20190924080152.7085-1-m.tretter@pengutronix.de \
    --to=m.tretter@pengutronix.de \
    --cc=Thomas.Haemmerle@wolfvision.net \
    --cc=barebox@lists.infradead.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