firmware: qcom_scm: Check for NULL before dereferencing __scm

The function qcom_scm_mem_protect_region_id dereferences __scm without
checking for NULL and could potentially lead to a NULL pointer exception.
This scenario can happen if the clinet calls qcom_scm_mem_protect_region_id
before qcom_scm driver is even probed. Hence, check for NULL before
dereferencing it.

Change-Id: I1a9eba6d45ba8ebf73da80bca984b4dfad05042e
Signed-off-by: Ashok Vuyyuru <avuyyuru@codeaurora.org>
This commit is contained in:
Ashok Vuyyuru 2021-01-03 02:41:53 +05:30
commit cceceac1d8
2 changed files with 3 additions and 2 deletions

View file

@ -1207,7 +1207,7 @@ int __qcom_scm_mem_protect_region_id(struct device *dev, phys_addr_t paddr,
desc.args[0] = paddr;
desc.args[1] = size;
desc.arginfo = QCOM_SCM_ARGS(2);
desc.arginfo = QCOM_SCM_ARGS(2, QCOM_SCM_RO, QCOM_SCM_VAL);
ret = qcom_scm_call(dev, &desc);

View file

@ -452,7 +452,8 @@ EXPORT_SYMBOL(qcom_scm_mem_protect_video);
int qcom_scm_mem_protect_region_id(phys_addr_t paddr, size_t size)
{
return __qcom_scm_mem_protect_region_id(__scm->dev, paddr, size);
return __qcom_scm_mem_protect_region_id(__scm ? __scm->dev : NULL,
paddr, size);
}
EXPORT_SYMBOL(qcom_scm_mem_protect_region_id);