From 32b29d83ff2b0d588d6e81830731b00fe56f8ee6 Mon Sep 17 00:00:00 2001 From: Mitchel Humpherys Date: Tue, 13 Oct 2015 11:19:24 -0700 Subject: [PATCH] qcom: scm: Be careful with side-effects from is_scm_armv8 Currently, when deciding which version of scm call to make in scm_call2, we check the scm_version variable. However, the scm_version variable is only initialized as a side-effect of calling is_scm_armv8, which isn't called anywhere in scm_call2. So if someone makes an scm_call2 before is_scm_armv8 has been called then they could get the wrong scm version. Fix this by calling is_scm_armv8 at the top of the scm_call2 function (and bailing out if it's not v8 since scm_call2 only supports v8 forward). Similarly for scm_call2_atomic. Since is_scm_armv8 caches its result the performance overhead of calling on every invocation of scm_call2 should be negligible. Change-Id: I46d2423ae2e4b5204fc5eefa1c6660c3c95a95b0 Signed-off-by: Mitchel Humpherys --- drivers/soc/qcom/scm.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/soc/qcom/scm.c b/drivers/soc/qcom/scm.c index 2635329ccdb3..13362cc23ea1 100644 --- a/drivers/soc/qcom/scm.c +++ b/drivers/soc/qcom/scm.c @@ -637,6 +637,9 @@ int scm_call2(u32 fn_id, struct scm_desc *desc) int ret, retry_count = 0; u64 x0; + if (unlikely(!is_scm_armv8())) + return -ENODEV; + ret = allocate_extra_arg_buffer(desc, GFP_KERNEL); if (ret) return ret; @@ -705,6 +708,9 @@ int scm_call2_atomic(u32 fn_id, struct scm_desc *desc) int ret; u64 x0; + if (unlikely(!is_scm_armv8())) + return -ENODEV; + ret = allocate_extra_arg_buffer(desc, GFP_ATOMIC); if (ret) return ret;