mach-snapdragon: dram: fix SMEM error pointer check
Subsystems (2)
PATCH 1/1 mach-snapdragon: dram: fix SMEM error pointer check
qcom_smem_get() reports failure with an ERR_PTR(), for example -ENOENT when the item is missing or -EPROBE_DEFER when SMEM is not ready, and never returns NULL. The check in qcom_parse_memory_smem() only tests for NULL, so an error pointer is treated as a valid RAM partition table and header->version is then dereferenced.
Use IS_ERR_OR_NULL() and return the error from qcom_smem_get() so that qcom_parse_memory() reports a missing memory map through its existing error path instead of faulting on a bogus pointer.
--- arch/arm/mach-snapdragon/dram.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
arch/arm/mach-snapdragon/dram.c +3 -2
@@ -8,6 +8,7 @@#include <asm-generic/unaligned.h> #include <dm.h> +#include <linux/err.h> #include <log.h> #include <sort.h> #include <soc/qcom/smem.h>
@@ -92,9 +93,9 @@ static int qcom_parse_memory_smem(phys_addr_t *ram_end) } header =qcom_smem_get (QCOM_SMEM_HOST_ANY ,SMEM_USABLE_RAM_PARTITION_TABLE , &size); -if (!header) { +if (IS_ERR_OR_NULL (header)) {debug ("Failed to find SMEM partition.\n" ); -return -ENODEV ; +return header ?PTR_ERR (header) : -ENODEV ; } ver = header->version;
---
base-commit: e36b675ebc4c41f1f4187c46d363d581c371d538
change-id: 20261020-dram-smem-errptr-e070f4d5e8fe
Best regards,
Signature · 1 line
Vandhiadevan Karunamoorthy <[email protected]>
On Tue, 20 Oct 2026 at 11:59, Vandhiadevan Karunamoorthy wrote: