From: Chen Ni <nichen@iscas.ac.cn>
To: sudeep.holla@kernel.org, cristian.marussi@arm.com
Cc: sumit.garg@oss.qualcomm.com, jens.wiklander@linaro.org,
arm-scmi@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
Chen Ni <nichen@iscas.ac.cn>
Subject: [PATCH] firmware: arm_scmi: optee: Check return value of tee_shm_get_va()
Date: Thu, 5 Mar 2026 15:15:33 +0800 [thread overview]
Message-ID: <20260305071533.930896-1-nichen@iscas.ac.cn> (raw)
The function tee_shm_get_va() can return an error pointer if the shared
memory is not properly mapped or if the offset is invalid. Without this
check, passing the error pointer to subsequent memory operations could
lead to a kernel panic.
Add a check for IS_ERR() on the return value of tee_shm_get_va().
Fixes: db9cc5e67778 ("firmware: arm_scmi: Make OPTEE transport a standalone driver")
Signed-off-by: Chen Ni <nichen@iscas.ac.cn>
---
drivers/firmware/arm_scmi/transports/optee.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/drivers/firmware/arm_scmi/transports/optee.c b/drivers/firmware/arm_scmi/transports/optee.c
index 07ae18d5279d..a6774152c205 100644
--- a/drivers/firmware/arm_scmi/transports/optee.c
+++ b/drivers/firmware/arm_scmi/transports/optee.c
@@ -340,6 +340,13 @@ static int setup_dynamic_shmem(struct device *dev, struct scmi_optee_channel *ch
}
shbuf = tee_shm_get_va(channel->tee_shm, 0);
+ if (IS_ERR(shbuf)) {
+ dev_err(channel->cinfo->dev, "failed to get shared memory VA\n");
+ tee_shm_free(channel->tee_shm);
+ channel->tee_shm = NULL;
+ return PTR_ERR(shbuf);
+ }
+
memset(shbuf, 0, msg_size);
channel->req.msg = shbuf;
channel->rx_len = msg_size;
--
2.25.1
next reply other threads:[~2026-03-05 7:18 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-05 7:15 Chen Ni [this message]
2026-03-05 9:19 ` [PATCH] firmware: arm_scmi: optee: Check return value of tee_shm_get_va() Dan Carpenter
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=20260305071533.930896-1-nichen@iscas.ac.cn \
--to=nichen@iscas.ac.cn \
--cc=arm-scmi@vger.kernel.org \
--cc=cristian.marussi@arm.com \
--cc=jens.wiklander@linaro.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=sudeep.holla@kernel.org \
--cc=sumit.garg@oss.qualcomm.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