Skip to contentSkip to conversation

firmware: qcom: scm: fix a NULL-pointer dereference

PATCH RESEND Applied Bartosz Golaszewski 3 participants 3 messages Sep 30, 2024 – Oct 7, 2024

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH RESEND v2 1/1 firmware: qcom: scm: fix a NULL-pointer dereference

From: Bartosz Golaszewski <[email protected]>

Some SCM calls can be invoked with __scm being NULL (the driver may not have been and will not be probed as there's no SCM entry in device-tree). Make sure we don't dereference a NULL pointer.

---
I dropped patch 2/2 and am resending this separately rebased on top of v6.12-rc1.

 drivers/firmware/qcom/qcom_scm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/firmware/qcom/qcom_scm.c +1 -1
index 10986cb11ec0..8bac4915c211 100644
@@ -216,7 +216,7 @@ static DEFINE_SPINLOCK(scm_query_lock);
 
 struct qcom_tzmem_pool *qcom_scm_get_tzmem_pool(void)
 {
-	return __scm->mempool;
+	return __scm ? __scm->mempool : NULL;
 }
 
 static enum qcom_scm_convention __get_convention(void)
Signature · 1 line
2.43.0
Reviewed-by on v2 1/1
#1 lore raw
Quoted 6 lines · Bartosz Golaszewski

From: Bartosz Golaszewski <[email protected]>

Some SCM calls can be invoked with __scm being NULL (the driver may not have been and will not be probed as there's no SCM entry in device-tree). Make sure we don't dereference a NULL pointer.

Quoted 8 lines
Quoted 20 lines

---
I dropped patch 2/2 and am resending this separately rebased on top of v6.12-rc1.

 drivers/firmware/qcom/qcom_scm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/firmware/qcom/qcom_scm.c +1 -1
index 10986cb11ec0..8bac4915c211 100644
@@ -216,7 +216,7 @@ static DEFINE_SPINLOCK(scm_query_lock);
 
 struct qcom_tzmem_pool *qcom_scm_get_tzmem_pool(void)
 {
-	return __scm->mempool;
+	return __scm ? __scm->mempool : NULL;
 }
 
 static enum qcom_scm_convention __get_convention(void)
Signature · 2 lines
Regards
Kuldeep
maintainer Applied
#2 lore raw
In reply to Bartosz Golaszewski
Quoted 5 lines · Bartosz Golaszewski

Some SCM calls can be invoked with __scm being NULL (the driver may not have been and will not be probed as there's no SCM entry in device-tree). Make sure we don't dereference a NULL pointer.

Applied, thanks!

[1/1] firmware: qcom: scm: fix a NULL-pointer dereference

      commit: ca61d6836e6f4442a77762e1074d2706a2a6e578

Best regards,

Signature · 1 line
Bjorn Andersson <[email protected]>