Skip to content

Commit

Permalink
soc: qcom: smem: Fix errant private access
Browse files Browse the repository at this point in the history
This patch corrects private partition item access.  Instead of falling back to
global for instances where we have an actual host and remote partition existing,
return the results of the private lookup.

Signed-off-by: Andy Gross <agross@codeaurora.org>
  • Loading branch information
Andy Gross committed Sep 9, 2015
1 parent 61e19ba commit 1891280
Showing 1 changed file with 6 additions and 12 deletions.
18 changes: 6 additions & 12 deletions drivers/soc/qcom/smem.c
Original file line number Diff line number Diff line change
Expand Up @@ -258,10 +258,6 @@ static int qcom_smem_alloc_private(struct qcom_smem *smem,
size_t alloc_size;
void *p;

/* We're not going to find it if there's no matching partition */
if (host >= SMEM_HOST_COUNT || !smem->partitions[host])
return -ENOENT;

phdr = smem->partitions[host];

p = (void *)phdr + sizeof(*phdr);
Expand Down Expand Up @@ -371,8 +367,9 @@ int qcom_smem_alloc(unsigned host, unsigned item, size_t size)
if (ret)
return ret;

ret = qcom_smem_alloc_private(__smem, host, item, size);
if (ret == -ENOENT)
if (host < SMEM_HOST_COUNT && __smem->partitions[host])
ret = qcom_smem_alloc_private(__smem, host, item, size);
else
ret = qcom_smem_alloc_global(__smem, item, size);

hwspin_unlock_irqrestore(__smem->hwlock, &flags);
Expand Down Expand Up @@ -428,10 +425,6 @@ static int qcom_smem_get_private(struct qcom_smem *smem,
struct smem_private_entry *hdr;
void *p;

/* We're not going to find it if there's no matching partition */
if (host >= SMEM_HOST_COUNT || !smem->partitions[host])
return -ENOENT;

phdr = smem->partitions[host];

p = (void *)phdr + sizeof(*phdr);
Expand Down Expand Up @@ -484,8 +477,9 @@ int qcom_smem_get(unsigned host, unsigned item, void **ptr, size_t *size)
if (ret)
return ret;

ret = qcom_smem_get_private(__smem, host, item, ptr, size);
if (ret == -ENOENT)
if (host < SMEM_HOST_COUNT && __smem->partitions[host])
ret = qcom_smem_get_private(__smem, host, item, ptr, size);
else
ret = qcom_smem_get_global(__smem, item, ptr, size);

hwspin_unlock_irqrestore(__smem->hwlock, &flags);
Expand Down

0 comments on commit 1891280

Please sign in to comment.