Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

soc: qcom: smem: fix qcom_smem_is_available and check if __smem is valid

Commit 7a94d5f31b54 ("soc: qcom: smem: better track SMEM uninitialized
state") changed the usage of __smem and init now as an error pointer
instead of NULL.

qcom_smem_is_available() wasn't updated to reflect this change and also
.qcom_smem_remove doesn't reset it on module exit.

Update both entry to reflect new handling of __smem.

Fixes: 7a94d5f31b54 ("soc: qcom: smem: better track SMEM uninitialized state")
Reported-by: Dan Carpenter <dan.carpenter@linaro.org>
Closes: https://lore.kernel.org/all/aSAnR3ECa04CoPqp@stanley.mountain/
Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
Reviewed-by: Konrad Dybcio <konrad.dybcio@oss.qualcomm.com>
Link: https://lore.kernel.org/r/20251122185002.26524-1-ansuelsmth@gmail.com
Signed-off-by: Bjorn Andersson <andersson@kernel.org>

authored by

Christian Marangi and committed by
Bjorn Andersson
f2090ebd 8f0b4cce

+3 -2
+3 -2
drivers/soc/qcom/smem.c
··· 396 396 */ 397 397 bool qcom_smem_is_available(void) 398 398 { 399 - return !!__smem; 399 + return !IS_ERR(__smem); 400 400 } 401 401 EXPORT_SYMBOL_GPL(qcom_smem_is_available); 402 402 ··· 1247 1247 { 1248 1248 platform_device_unregister(__smem->socinfo); 1249 1249 1250 - __smem = NULL; 1250 + /* Set to -EPROBE_DEFER to signal unprobed state */ 1251 + __smem = ERR_PTR(-EPROBE_DEFER); 1251 1252 } 1252 1253 1253 1254 static const struct of_device_id qcom_smem_of_match[] = {