aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlex Elder <elder@linaro.org>2018-06-25 20:58:47 -0400
committerAndy Gross <andy.gross@linaro.org>2018-09-13 17:56:55 -0400
commiteba757022fc2935c8a1392278a26d86761a70c60 (patch)
treebf2d8b5932fe9891f575445160b30b641567a631
parent100d26e8ce65f33d229912be3bc563a93a786186 (diff)
soc: qcom: smem: always ignore partitions with 0 offset or size
In qcom_smem_enumerate_partitions(), any partition table entry having a zero offset or size field is ignored. Move those checks earlier in the loop, because there's no sense in examining the host fields for those entries. Add the same checks in qcom_smem_set_global_partition(), so the scan for the global partition skips over these invalid entries. This allows a later check for zero size or offset once the global entry is found to be eliminated. Signed-off-by: Alex Elder <elder@linaro.org> Signed-off-by: Andy Gross <andy.gross@linaro.org>
-rw-r--r--drivers/soc/qcom/smem.c23
1 files changed, 10 insertions, 13 deletions
diff --git a/drivers/soc/qcom/smem.c b/drivers/soc/qcom/smem.c
index 938ffb01d155..9378bee4d7d6 100644
--- a/drivers/soc/qcom/smem.c
+++ b/drivers/soc/qcom/smem.c
@@ -743,9 +743,13 @@ static int qcom_smem_set_global_partition(struct qcom_smem *smem)
743 743
744 for (i = 0; i < le32_to_cpu(ptable->num_entries); i++) { 744 for (i = 0; i < le32_to_cpu(ptable->num_entries); i++) {
745 entry = &ptable->entry[i]; 745 entry = &ptable->entry[i];
746 if (!le32_to_cpu(entry->offset))
747 continue;
748 if (!le32_to_cpu(entry->size))
749 continue;
750
746 host0 = le16_to_cpu(entry->host0); 751 host0 = le16_to_cpu(entry->host0);
747 host1 = le16_to_cpu(entry->host1); 752 host1 = le16_to_cpu(entry->host1);
748
749 if (host0 == SMEM_GLOBAL_HOST && host0 == host1) { 753 if (host0 == SMEM_GLOBAL_HOST && host0 == host1) {
750 found = true; 754 found = true;
751 break; 755 break;
@@ -757,11 +761,6 @@ static int qcom_smem_set_global_partition(struct qcom_smem *smem)
757 return -EINVAL; 761 return -EINVAL;
758 } 762 }
759 763
760 if (!le32_to_cpu(entry->offset) || !le32_to_cpu(entry->size)) {
761 dev_err(smem->dev, "Invalid entry for global partition\n");
762 return -EINVAL;
763 }
764
765 header = smem->regions[0].virt_base + le32_to_cpu(entry->offset); 764 header = smem->regions[0].virt_base + le32_to_cpu(entry->offset);
766 host0 = le16_to_cpu(header->host0); 765 host0 = le16_to_cpu(header->host0);
767 host1 = le16_to_cpu(header->host1); 766 host1 = le16_to_cpu(header->host1);
@@ -810,18 +809,16 @@ static int qcom_smem_enumerate_partitions(struct qcom_smem *smem,
810 809
811 for (i = 0; i < le32_to_cpu(ptable->num_entries); i++) { 810 for (i = 0; i < le32_to_cpu(ptable->num_entries); i++) {
812 entry = &ptable->entry[i]; 811 entry = &ptable->entry[i];
813 host0 = le16_to_cpu(entry->host0);
814 host1 = le16_to_cpu(entry->host1);
815
816 if (host0 != local_host && host1 != local_host)
817 continue;
818
819 if (!le32_to_cpu(entry->offset)) 812 if (!le32_to_cpu(entry->offset))
820 continue; 813 continue;
821
822 if (!le32_to_cpu(entry->size)) 814 if (!le32_to_cpu(entry->size))
823 continue; 815 continue;
824 816
817 host0 = le16_to_cpu(entry->host0);
818 host1 = le16_to_cpu(entry->host1);
819 if (host0 != local_host && host1 != local_host)
820 continue;
821
825 if (host0 == local_host) 822 if (host0 == local_host)
826 remote_host = host1; 823 remote_host = host1;
827 else 824 else