Skip to content

Commit

Permalink
soc: qcom: smem: fix qcom_smem_set_global_partition()
Browse files Browse the repository at this point in the history
If there is at least one entry in the partition table, but no global
entry, the qcom_smem_set_global_partition() should return an error
just like it does if there are no partition table entries.

It turns out the function still returns an error in this case, but
it waits to do so until it has mistakenly treated the last entry in
the table as if it were the global entry found.

Fix the function to return immediately if no global entry is found
in the table.

Signed-off-by: Alex Elder <elder@linaro.org>
Reviewed-by: Bjorn Andersson <bjorn.andersson@linaro.org>
Signed-off-by: Andy Gross <andy.gross@linaro.org>
  • Loading branch information
Alex Elder authored and Andy Gross committed May 25, 2018
1 parent 8377f81 commit 8fa1a21
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions drivers/soc/qcom/smem.c
Original file line number Diff line number Diff line change
Expand Up @@ -698,9 +698,10 @@ static u32 qcom_smem_get_item_count(struct qcom_smem *smem)
static int qcom_smem_set_global_partition(struct qcom_smem *smem)
{
struct smem_partition_header *header;
struct smem_ptable_entry *entry = NULL;
struct smem_ptable_entry *entry;
struct smem_ptable *ptable;
u32 host0, host1, size;
bool found = false;
int i;

ptable = qcom_smem_get_ptable(smem);
Expand All @@ -712,11 +713,13 @@ static int qcom_smem_set_global_partition(struct qcom_smem *smem)
host0 = le16_to_cpu(entry->host0);
host1 = le16_to_cpu(entry->host1);

if (host0 == SMEM_GLOBAL_HOST && host0 == host1)
if (host0 == SMEM_GLOBAL_HOST && host0 == host1) {
found = true;
break;
}
}

if (!entry) {
if (!found) {
dev_err(smem->dev, "Missing entry for global partition\n");
return -EINVAL;
}
Expand Down

0 comments on commit 8fa1a21

Please sign in to comment.