From: Ahmad Fatoum <a.fatoum@barebox.org>
To: barebox@lists.infradead.org
Cc: Ahmad Fatoum <a.fatoum@barebox.org>
Subject: [PATCH v2 09/13] security: blobgen: add easy way to check for existent providers
Date: Wed, 13 Aug 2025 16:33:41 +0200 [thread overview]
Message-ID: <20250813143345.3758653-10-a.fatoum@barebox.org> (raw)
In-Reply-To: <20250813143345.3758653-1-a.fatoum@barebox.org>
blobgen_get() expects the user to name the blobgen instance to be used.
For general informational purposes, it would be nice to just check if
any provider is registered at all, so make that possible by accepting a
NULL filter argument.
Signed-off-by: Ahmad Fatoum <a.fatoum@barebox.org>
---
v1 -> v2:
- no change
---
include/blobgen.h | 7 +++++++
security/blobgen.c | 18 +++++++++++-------
2 files changed, 18 insertions(+), 7 deletions(-)
diff --git a/include/blobgen.h b/include/blobgen.h
index 9f8876cee045..00674ef40f73 100644
--- a/include/blobgen.h
+++ b/include/blobgen.h
@@ -44,7 +44,14 @@ struct blobgen {
int blob_gen_register(struct device *dev, struct blobgen *bg);
+#ifdef CONFIG_BLOBGEN
struct blobgen *blobgen_get(const char *name);
+#else
+static inline struct blobgen *blobgen_get(const char *name)
+{
+ return NULL;
+}
+#endif
int blob_encrypt(struct blobgen *blg, const char *modifier, const void *plain,
int plainsize, void **blob, int *blobsize);
diff --git a/security/blobgen.c b/security/blobgen.c
index 0a4e192a271f..df42c8f6f1bc 100644
--- a/security/blobgen.c
+++ b/security/blobgen.c
@@ -50,24 +50,28 @@ int blob_gen_register(struct device *dev, struct blobgen *bg)
/**
* blobgen_get - get a blob generator of given name
- * @name: The name of the blob generator to look for
+ * @name: The name of the blob generator to look for or NULL
*
- * Finds a blob generator by name and returns it. Returns NULL if none is found.
+ * Finds a blob generator by name and returns it.
+ * If name is NULL, returns the first blob generator encountered.
+ * Returns NULL if none is found.
*/
struct blobgen *blobgen_get(const char *name)
{
- struct device *dev;
+ struct device *dev = NULL;
struct blobgen *bg;
if (!name)
return bg_default;
- dev = get_device_by_name(name);
- if (!dev)
- return NULL;
+ if (name) {
+ dev = get_device_by_name(name);
+ if (!dev)
+ return NULL;
+ }
list_for_each_entry(bg, &blobs, list) {
- if (dev == &bg->dev)
+ if (!dev || dev == &bg->dev)
return bg;
}
--
2.39.5
next prev parent reply other threads:[~2025-08-13 14:51 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-08-13 14:33 [PATCH v2 00/13] commands: add bfetch/buds of command redirection Ahmad Fatoum
2025-08-13 14:33 ` [PATCH v2 01/13] common: introduce structured I/O Ahmad Fatoum
2025-08-13 14:33 ` [PATCH v2 02/13] ARM: cpuinfo: support structio output Ahmad Fatoum
2025-08-13 14:33 ` [PATCH v2 03/13] commands: uptime: enable structured I/O Ahmad Fatoum
2025-08-13 14:33 ` [PATCH v2 04/13] string: implement strv_length helper Ahmad Fatoum
2025-08-13 14:33 ` [PATCH v2 05/13] ARM: psci: client: add PSCI version/method parameters Ahmad Fatoum
2025-08-13 14:33 ` [PATCH v2 06/13] net: move netmask_to_prefix into header Ahmad Fatoum
2025-08-13 14:33 ` [PATCH v2 07/13] optee: add revision info to tee devinfo output Ahmad Fatoum
2025-08-13 14:33 ` [PATCH v2 08/13] tee: enable structured I/O in devinfo handler Ahmad Fatoum
2025-08-13 14:33 ` Ahmad Fatoum [this message]
2025-08-13 14:33 ` [PATCH v2 10/13] clk: implement clk_have_nonfixed_providers Ahmad Fatoum
2025-08-13 14:33 ` [PATCH v2 11/13] commands: introduce bfetch command Ahmad Fatoum
2025-08-13 14:33 ` [PATCH v2 12/13] configs: enable bfetch in some popular defconfigs Ahmad Fatoum
2025-08-13 14:33 ` [PATCH v2 13/13] hush: structio: silence missing command error message Ahmad Fatoum
2025-08-14 10:53 ` [PATCH v2 00/13] commands: add bfetch/buds of command redirection Sascha Hauer
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=20250813143345.3758653-10-a.fatoum@barebox.org \
--to=a.fatoum@barebox.org \
--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