LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Alex Elder <elder@linaro.org>
To: andy.gross@linaro.org
Cc: clew@codeaurora.org, aneela@codeaurora.org,
	david.brown@linaro.org, linux-arm-msm@vger.kernel.org,
	linux-soc@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH 5/6] soc: qcom: smem: fix qcom_smem_set_global_partition()
Date: Tue, 10 Apr 2018 17:25:41 -0500	[thread overview]
Message-ID: <20180410222542.29474-6-elder@linaro.org> (raw)
In-Reply-To: <20180410222542.29474-1-elder@linaro.org>

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>
---
 drivers/soc/qcom/smem.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/drivers/soc/qcom/smem.c b/drivers/soc/qcom/smem.c
index 0ed263055988..6e42599b70d4 100644
--- a/drivers/soc/qcom/smem.c
+++ b/drivers/soc/qcom/smem.c
@@ -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);
@@ -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;
 	}
-- 
2.14.1

  parent reply	other threads:[~2018-04-10 23:42 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-04-10 22:25 [PATCH 0/6] soc: qcom: smem: bug fixes Alex Elder
2018-04-10 22:25 ` [PATCH 1/6] soc: qcom: smem: fix first cache entry calculation Alex Elder
2018-04-25  4:35   ` Bjorn Andersson
2018-04-10 22:25 ` [PATCH 2/6] soc: qcom: smem: return proper type for cached entry functions Alex Elder
2018-04-25  4:39   ` Bjorn Andersson
2018-04-10 22:25 ` [PATCH 3/6] soc: qcom: smem: byte swap values properly Alex Elder
2018-04-25  4:44   ` Bjorn Andersson
2018-04-10 22:25 ` [PATCH 4/6] soc: qcom: smem: fix off-by-one error in qcom_smem_alloc_private() Alex Elder
2018-04-25  4:48   ` Bjorn Andersson
2018-04-10 22:25 ` Alex Elder [this message]
2018-04-25  4:50   ` [PATCH 5/6] soc: qcom: smem: fix qcom_smem_set_global_partition() Bjorn Andersson
2018-04-10 22:25 ` [PATCH 6/6] soc: qcom: smem: check sooner in qcom_smem_set_global_partition() Alex Elder
2018-04-25  4:52   ` Bjorn Andersson
2018-04-20 12:11 ` [PATCH 0/6] soc: qcom: smem: bug fixes Alex Elder
2018-04-25  4:07   ` Andy Gross
2018-04-25 11:37     ` Alex Elder

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180410222542.29474-6-elder@linaro.org \
    --to=elder@linaro.org \
    --cc=andy.gross@linaro.org \
    --cc=aneela@codeaurora.org \
    --cc=clew@codeaurora.org \
    --cc=david.brown@linaro.org \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-soc@vger.kernel.org \
    --subject='Re: [PATCH 5/6] soc: qcom: smem: fix qcom_smem_set_global_partition()' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).