Linux-ARM-Kernel Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] firmware: arm_scmi: optee: Check return value of tee_shm_get_va()
@ 2026-03-05  7:15 Chen Ni
  2026-03-05  9:19 ` Dan Carpenter
  0 siblings, 1 reply; 2+ messages in thread
From: Chen Ni @ 2026-03-05  7:15 UTC (permalink / raw)
  To: sudeep.holla, cristian.marussi
  Cc: sumit.garg, jens.wiklander, arm-scmi, linux-arm-kernel, Chen Ni

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



^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-03-05  9:19 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-05  7:15 [PATCH] firmware: arm_scmi: optee: Check return value of tee_shm_get_va() Chen Ni
2026-03-05  9:19 ` Dan Carpenter

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox