From: Sascha Hauer <s.hauer@pengutronix.de>
To: Barebox List <barebox@lists.infradead.org>
Cc: "Claude Opus 4.6" <noreply@anthropic.com>
Subject: [PATCH 2/2] optee: skip registration of already known TEE bus devices
Date: Thu, 19 Mar 2026 08:03:04 +0100 [thread overview]
Message-ID: <20260319070304.1965024-2-s.hauer@pengutronix.de> (raw)
In-Reply-To: <20260319070304.1965024-1-s.hauer@pengutronix.de>
optee_enumerate_devices() may be called multiple times, e.g. when a
new RPMB device appears. Check if a device with the same name is
already registered on the TEE bus before registering it again.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
drivers/tee/optee/device.c | 11 ++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)
diff --git a/drivers/tee/optee/device.c b/drivers/tee/optee/device.c
index f5e03630b1..ab05a4dfc9 100644
--- a/drivers/tee/optee/device.c
+++ b/drivers/tee/optee/device.c
@@ -57,14 +57,23 @@ static int get_devices(struct tee_context *ctx, u32 session,
static int optee_register_device(const uuid_t *device_uuid)
{
struct tee_client_device *optee_device = NULL;
+ struct device *dev;
+ char name[39];
int rc;
+ snprintf(name, sizeof(name), "optee-ta-%pUb", device_uuid);
+
+ dev = bus_find_device_by_name(&tee_bus_type, NULL, name);
+ if (dev)
+ return 0;
+
optee_device = kzalloc(sizeof(*optee_device), GFP_KERNEL);
if (!optee_device)
return -ENOMEM;
+ optee_device->dev.id = DEVICE_ID_SINGLE;
optee_device->dev.bus = &tee_bus_type;
- if (dev_set_name(&optee_device->dev, "optee-ta-%pUb", device_uuid)) {
+ if (dev_set_name(&optee_device->dev, "%s", name)) {
kfree(optee_device);
return -ENOMEM;
}
--
2.47.3
next prev parent reply other threads:[~2026-03-19 7:03 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-19 7:03 [PATCH 1/2] optee: Explicitly ignore OPTEE_RPC_CMD_RPMB_* Sascha Hauer
2026-03-19 7:03 ` Sascha Hauer [this message]
2026-03-20 9:09 ` [PATCH] fixup! optee: skip registration of already known TEE bus devices Sascha Hauer
2026-03-20 6:35 ` [PATCH 1/2] optee: Explicitly ignore OPTEE_RPC_CMD_RPMB_* 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=20260319070304.1965024-2-s.hauer@pengutronix.de \
--to=s.hauer@pengutronix.de \
--cc=barebox@lists.infradead.org \
--cc=noreply@anthropic.com \
/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