firmware: qcom_scm: Check for NULL before dereferencing __scm

The function qcom_scm_get_sec_dump_state 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_get_sec_dump_state
before qcom_scm driver is even probed. Hence, check for NULL before
dereferencing it.

Change-Id: Ic6f7c2b2d616645ea69a8c594c90dc01d689637f
Signed-off-by: Raghavendra Rao Ananta <rananta@codeaurora.org>
This commit is contained in:
Raghavendra Rao Ananta 2019-12-06 09:52:29 -08:00
commit 54e781e95b

View file

@ -329,7 +329,7 @@ static const struct reset_control_ops qcom_scm_pas_reset_ops = {
int qcom_scm_get_sec_dump_state(u32 *dump_state)
{
return __qcom_scm_get_sec_dump_state(__scm->dev,
return __qcom_scm_get_sec_dump_state(__scm ? __scm->dev : NULL,
dump_state);
}
EXPORT_SYMBOL(qcom_scm_get_sec_dump_state);