From: Hans de Goede <johannes.goede@oss.qualcomm.com>
To: Bjorn Andersson <andersson@kernel.org>,
Cristian Marussi <cristian.marussi@arm.com>,
Sudeep Holla <sudeep.holla@kernel.org>
Cc: Hans de Goede <johannes.goede@oss.qualcomm.com>,
Daniel Lezcano <daniel.lezcano@oss.qualcomm.com>,
Bjorn Andersson <bjorn.andersson@oss.qualcomm.com>,
Frank.Li@kernel.org, arm-scmi@vger.kernel.org,
linux-arm-kernel@lists.infradead.org,
linux-arm-msm@vger.kernel.org, imx@lists.linux.dev,
linux-kernel@vger.kernel.org
Subject: [PATCH v6 3/4] firmware: arm_scmi: Fix scmi_protocol_device_unrequest() race
Date: Fri, 11 Sep 2026 17:23:28 +0200 [thread overview]
Message-ID: <20260911152329.5822-4-johannes.goede@oss.qualcomm.com> (raw)
In-Reply-To: <20260911152329.5822-1-johannes.goede@oss.qualcomm.com>
scmi_protocol_device_unrequest() unlocks scmi_requested_devices_mtx during
the notifier call. During this window phead might have been deleted by
another racing scmi_protocol_device_unrequest().
Re-acquire phead before cleaning it up to avoid this potential double
free problem.
Fixes: d3cd7c525fd2 ("firmware: arm_scmi: Refactor protocol device creation")
Signed-off-by: Hans de Goede <johannes.goede@oss.qualcomm.com>
---
Changes in v6:
- New patch in v6 of this series (Suggested by local Shashiko run on v5)
---
drivers/firmware/arm_scmi/bus.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/drivers/firmware/arm_scmi/bus.c b/drivers/firmware/arm_scmi/bus.c
index 6f667e4ffeed..651d4ba06574 100644
--- a/drivers/firmware/arm_scmi/bus.c
+++ b/drivers/firmware/arm_scmi/bus.c
@@ -173,7 +173,13 @@ static void scmi_protocol_device_unrequest(const struct scmi_device_id *id_table
}
}
- if (list_empty(phead)) {
+ /*
+ * Since scmi_requested_devices_mtx is unlocked during
+ * the notifier call phead might have been deleted by another
+ * racing scmi_protocol_device_unrequest(), re-acquire it here.
+ */
+ phead = idr_find(&scmi_requested_devices, id_table->protocol_id);
+ if (phead && list_empty(phead)) {
idr_remove(&scmi_requested_devices,
id_table->protocol_id);
kfree(phead);
--
2.55.0
next prev parent reply other threads:[~2026-09-11 15:23 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-11 15:23 [PATCH v6 0/4] firmware: arm_scmi: fix module auto-loading Hans de Goede
2026-09-11 15:23 ` [PATCH v6 1/4] module: add SCMI device table alias support Hans de Goede
2026-09-11 15:23 ` [PATCH v6 2/4] firmware: arm_scmi: Fix scmi_protocol_table_register() error handling Hans de Goede
2026-09-12 20:50 ` Abel Vesa
2026-09-12 20:57 ` Hans de Goede
2026-09-11 15:23 ` Hans de Goede [this message]
2026-09-15 14:21 ` [PATCH v6 3/4] firmware: arm_scmi: Fix scmi_protocol_device_unrequest() race Sudeep Holla
2026-09-18 9:26 ` Hans de Goede
2026-09-11 15:23 ` [PATCH v6 4/4] firmware: arm_scmi: Always create devices for standard protocols Hans de Goede
2026-09-15 14:24 ` [PATCH v6 0/4] firmware: arm_scmi: fix module auto-loading Sudeep Holla
2026-09-18 9:30 ` Hans de Goede
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=20260911152329.5822-4-johannes.goede@oss.qualcomm.com \
--to=johannes.goede@oss.qualcomm.com \
--cc=Frank.Li@kernel.org \
--cc=andersson@kernel.org \
--cc=arm-scmi@vger.kernel.org \
--cc=bjorn.andersson@oss.qualcomm.com \
--cc=cristian.marussi@arm.com \
--cc=daniel.lezcano@oss.qualcomm.com \
--cc=imx@lists.linux.dev \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=sudeep.holla@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
all inboxes | Powered by JetHome®