[PATCH] soc: qcom: smem: Fix endian-unaware access of num_entries

Jens Reidel posted 1 patch 2 months, 1 week ago
drivers/soc/qcom/smem.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
[PATCH] soc: qcom: smem: Fix endian-unaware access of num_entries
Posted by Jens Reidel 2 months, 1 week ago
Add a missing le32_to_cpu when accessing num_entries, which is always a
little endian integer.

Fixes booting on Xiaomi Mi 9T (xiaomi-davinci) in big endian.

Signed-off-by: Jens Reidel <adrian@mainlining.org>
---
 drivers/soc/qcom/smem.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/soc/qcom/smem.c b/drivers/soc/qcom/smem.c
index cf425930539e..c4c45f15dca4 100644
--- a/drivers/soc/qcom/smem.c
+++ b/drivers/soc/qcom/smem.c
@@ -898,7 +898,7 @@ static u32 qcom_smem_get_item_count(struct qcom_smem *smem)
 	if (IS_ERR_OR_NULL(ptable))
 		return SMEM_ITEM_COUNT;
 
-	info = (struct smem_info *)&ptable->entry[ptable->num_entries];
+	info = (struct smem_info *)&ptable->entry[le32_to_cpu(ptable->num_entries)];
 	if (memcmp(info->magic, SMEM_INFO_MAGIC, sizeof(info->magic)))
 		return SMEM_ITEM_COUNT;
 
-- 
2.50.1
Re: [PATCH] soc: qcom: smem: Fix endian-unaware access of num_entries
Posted by Bjorn Andersson 1 month, 3 weeks ago
On Sun, 27 Jul 2025 01:56:46 +0200, Jens Reidel wrote:
> Add a missing le32_to_cpu when accessing num_entries, which is always a
> little endian integer.
> 
> Fixes booting on Xiaomi Mi 9T (xiaomi-davinci) in big endian.
> 
> 

Applied, thanks!

[1/1] soc: qcom: smem: Fix endian-unaware access of num_entries
      commit: 19e7aa0e9e46d0ad111a4af55b3d681b6ad945e0

Best regards,
-- 
Bjorn Andersson <andersson@kernel.org>