mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Philip Radford <philip.radford@arm.com>
To: linux-kernel@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org, arm-scmi@vger.kernel.org
Cc: sudeep.holla@arm.com, cristian.marussi@arm.com,
	philip.radford@arm.com, Sashiko <sashiko-bot@kernel.org>
Subject: [PATCH 2/2] firmware: arm_scmi: null pointer dereference in scmi_protocol_table_register()
Date: Mon, 16 Nov 2026 12:31:53 +0000	[thread overview]
Message-ID: <20261116123153.2672631-3-philip.radford@arm.com> (raw)
In-Reply-To: <20261116123153.2672631-1-philip.radford@arm.com>

Add checks to avoid dereferencing a null pointer in
scmi_protocol_table_register() and scmi_protocol_table_unregister()

Reported-by: Sashiko <sashiko-bot@kernel.org>
Closes: https://sashiko.dev/#/bug/linux-7330d90b-8d81-478a-a227-4aa6f19393ba
Fixes: 2858f6e5f064 ("firmware: arm_scmi: Add multiple protocols registration support")
Signed-off-by: Philip Radford <philip.radford@arm.com>
---
 drivers/firmware/arm_scmi/bus.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/drivers/firmware/arm_scmi/bus.c b/drivers/firmware/arm_scmi/bus.c
index 25197197db8e..337aa445e42d 100644
--- a/drivers/firmware/arm_scmi/bus.c
+++ b/drivers/firmware/arm_scmi/bus.c
@@ -186,6 +186,9 @@ static int scmi_protocol_table_register(const struct scmi_device_id *id_table)
 	const struct scmi_device_id *entry;
 	int ret;
 
+	if (!id_table)
+		return -ENOENT;
+
 	for (entry = id_table; entry->name[0]; entry++) {
 		ret = scmi_protocol_device_request(entry);
 		if (ret)
@@ -206,8 +209,11 @@ scmi_protocol_table_unregister(const struct scmi_device_id *id_table)
 {
 	const struct scmi_device_id *entry;
 
-	for (entry = id_table; entry->name[0]; entry++)
-		scmi_protocol_device_unrequest(entry);
+	if (id_table) {
+		for (entry = id_table; entry->name[0]; entry++)
+			scmi_protocol_device_unrequest(entry);
+	}
+
 }
 
 static bool scmi_device_is_transport(const struct scmi_device *scmi_dev)
-- 
2.34.1


  parent reply	other threads:[~2026-11-16 12:32 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-16 12:31 [PATCH 0/2] firmware: arm_scmi: fix shared memory and protocol table Philip Radford
2026-11-16 12:31 ` [PATCH 1/2] firmware: arm_scmi: uninitialized reg_io_width in shmem_setup_iomap() Philip Radford
2026-11-16 12:31 ` Philip Radford [this message]
2026-11-19 13:55 ` [PATCH 0/2] firmware: arm_scmi: fix shared memory and protocol table Sudeep Holla
2026-11-19 15:41   ` Philip Radford

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=20261116123153.2672631-3-philip.radford@arm.com \
    --to=philip.radford@arm.com \
    --cc=arm-scmi@vger.kernel.org \
    --cc=cristian.marussi@arm.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=sashiko-bot@kernel.org \
    --cc=sudeep.holla@arm.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

all inboxes | Powered by JetHome®