LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Bjorn Andersson <bjorn.andersson@linaro.org>
To: Alex Elder <elder@linaro.org>
Cc: andy.gross@linaro.org, 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: Re: [PATCH 3/6] soc: qcom: smem: byte swap values properly
Date: Tue, 24 Apr 2018 21:44:25 -0700	[thread overview]
Message-ID: <20180425044425.GG2052@tuxbook-pro> (raw)
In-Reply-To: <20180410222542.29474-4-elder@linaro.org>

On Tue 10 Apr 15:25 PDT 2018, Alex Elder wrote:

> Two places report an error when a partition header is found to
> not contain the right canary value.  The error messages do not
> properly byte swap the host ids.  Fix this, and adjust the format
> specificier to match the 16-bit unsigned data type.
> 
> Move the error handling for a bad canary value to the end of
> qcom_smem_alloc_private().  This avoids some long lines, and
> reduces the distraction of handling this unexpected problem.
> 
> Signed-off-by: Alex Elder <elder@linaro.org>

Reviewed-by: Bjorn Andersson <bjorn.andersson@linaro.org>

Regards,
Bjorn

> ---
>  drivers/soc/qcom/smem.c | 18 +++++++++---------
>  1 file changed, 9 insertions(+), 9 deletions(-)
> 
> diff --git a/drivers/soc/qcom/smem.c b/drivers/soc/qcom/smem.c
> index 3102aa94aec2..82f0908b90e1 100644
> --- a/drivers/soc/qcom/smem.c
> +++ b/drivers/soc/qcom/smem.c
> @@ -365,13 +365,8 @@ static int qcom_smem_alloc_private(struct qcom_smem *smem,
>  	cached = phdr_to_last_cached_entry(phdr);
>  
>  	while (hdr < end) {
> -		if (hdr->canary != SMEM_PRIVATE_CANARY) {
> -			dev_err(smem->dev,
> -				"Found invalid canary in hosts %d:%d partition\n",
> -				phdr->host0, phdr->host1);
> -			return -EINVAL;
> -		}
> -
> +		if (hdr->canary != SMEM_PRIVATE_CANARY)
> +			goto bad_canary;
>  		if (le16_to_cpu(hdr->item) == item)
>  			return -EEXIST;
>  
> @@ -400,6 +395,11 @@ static int qcom_smem_alloc_private(struct qcom_smem *smem,
>  	le32_add_cpu(&phdr->offset_free_uncached, alloc_size);
>  
>  	return 0;
> +bad_canary:
> +	dev_err(smem->dev, "Found invalid canary in hosts %hu:%hu partition\n",
> +		le16_to_cpu(phdr->host0), le16_to_cpu(phdr->host1));
> +
> +	return -EINVAL;
>  }
>  
>  static int qcom_smem_alloc_global(struct qcom_smem *smem,
> @@ -563,8 +563,8 @@ static void *qcom_smem_get_private(struct qcom_smem *smem,
>  	return ERR_PTR(-ENOENT);
>  
>  invalid_canary:
> -	dev_err(smem->dev, "Found invalid canary in hosts %d:%d partition\n",
> -			phdr->host0, phdr->host1);
> +	dev_err(smem->dev, "Found invalid canary in hosts %hu:%hu partition\n",
> +			le16_to_cpu(phdr->host0), le16_to_cpu(phdr->host1));
>  
>  	return ERR_PTR(-EINVAL);
>  }
> -- 
> 2.14.1
> 

  reply	other threads:[~2018-04-25  4:43 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 [this message]
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 ` [PATCH 5/6] soc: qcom: smem: fix qcom_smem_set_global_partition() Alex Elder
2018-04-25  4:50   ` 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=20180425044425.GG2052@tuxbook-pro \
    --to=bjorn.andersson@linaro.org \
    --cc=andy.gross@linaro.org \
    --cc=aneela@codeaurora.org \
    --cc=clew@codeaurora.org \
    --cc=david.brown@linaro.org \
    --cc=elder@linaro.org \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-soc@vger.kernel.org \
    --subject='Re: [PATCH 3/6] soc: qcom: smem: byte swap values properly' \
    /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).