Received: by 10.192.165.148 with SMTP id m20csp249187imm; Tue, 24 Apr 2018 21:44:54 -0700 (PDT) X-Google-Smtp-Source: AIpwx4+VIhl5tGQDyGU3xb+9JE44JXWs7nfYH3owVjIbG7o+jui/g0F/LspZONoxXSkbhI1UhKwf X-Received: by 2002:a17:902:ba88:: with SMTP id k8-v6mr27071305pls.305.1524631494506; Tue, 24 Apr 2018 21:44:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524631494; cv=none; d=google.com; s=arc-20160816; b=mv2oJ1/7G8muwepeNpkUxB9/6d+CPcHI18Medo561Anoby/peQS5jbGkONjsuZdiGR hXLcBHEcxwYU3ddYIMI3cnH/w8Pi2NA+/WfmUSK2OJqZ8FeYHpQ/d7yq5aC8NzdKbPR8 tBG7ZABtVanL786hQx0QWhZyfQbBOzbRwx3JXA2JL8m335gIBPBP06tpX1rX3mqN/ye8 rzxlljuMMuMzMbO2/kAsP3B81IMsfu73QfkKJh69YF6NJhnwr+W/E70nFh3lzeBAaYfj q3P47cjXIjXk7xRE4vyQvl2IBlm641EwecCnQONH9Y35BhwmknHAdkkAdPtXMDz5GhGO hjGg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature:arc-authentication-results; bh=WCULyhxxMOL5GCdtlAmJgqOWiSFxOFMn2Pv0/mQ0Io8=; b=Gl7wo+ZLL/2CpyY09JOQD50EhbsB3lyPtuLQJYfzKOctO0zK5e8VOf6Rd1gq+kWYxh ZR9h770OzPv93KZeUNtyUnzv2pOCwqaAfapgIgz/0IknG4kqszuppqpHGLrZKbrGp5zr WlQp33p0PMB0k/ddZImHDxAMZxqoSXzl9w3+Tnhi8Js5jJNmgordm9+37fDd8nGy3S1I oMhfcmdAhqFmr7gPYFuQyXhVB9ZWspS30U+hGm64upFCzHEnbz4aUs+xIN9vNfisu7ly zjMsv8vKPQFwUzWMDoAJLggZ3n17vrPH1KUmBKgq/77sBAS45PS5wREdc58jderZVybg h3LQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=NoJHbcue; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b8-v6si16379206plx.523.2018.04.24.21.44.39; Tue, 24 Apr 2018 21:44:54 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=NoJHbcue; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751304AbeDYEnW (ORCPT + 99 others); Wed, 25 Apr 2018 00:43:22 -0400 Received: from mail-pf0-f193.google.com ([209.85.192.193]:35132 "EHLO mail-pf0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750962AbeDYEnR (ORCPT ); Wed, 25 Apr 2018 00:43:17 -0400 Received: by mail-pf0-f193.google.com with SMTP id j5so14123414pfh.2 for ; Tue, 24 Apr 2018 21:43:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=WCULyhxxMOL5GCdtlAmJgqOWiSFxOFMn2Pv0/mQ0Io8=; b=NoJHbcueLgM7JArczDEBlMCrx6qcclcLfZK8U8Hv8LY2eXuyw/EZqsc1iVcP3n/QKu k629R21B/PijibPRzW1yEoZN1PDQxTaNsfiveitGcOdXI+Ptcj6zuOlkGHRLoTecN2he htkPUAiH7kJ5WquJss75WjRGOagIZmIhGepYc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=WCULyhxxMOL5GCdtlAmJgqOWiSFxOFMn2Pv0/mQ0Io8=; b=YaCMVN2inZroWMh/k/S9vrSDQUicYLIYaUaAWbFcj9FioWfQTdt0pOAXW6dmTs3B4Z UYIs9s3NS3W35878Ijwwxz30BtGuYYVPD4Wi6D2ZZOT6OJAXP4nj0VZDkxSfnZ26JLq1 Cci1GEKBtIc75J7wjT1SzL7A3fwiM9izcnE4U5Q8oy/ZnMpH5xRxHOhZI3NGhj0sBqPu 7u1abJsp+1vFd44opk52zbGt269CQ6j/q8/fv9yvcBdZ/RX9ZuxXwK35UYt1oKuc09tw cW2TgITCjKf215mgHLbEm2sGkMu8NoYLbHSCO6us4Cy7G8IpAZA2sWGUNdpTJs3K6ki4 3zeg== X-Gm-Message-State: ALQs6tDBLPKaHVVP8Z0vZw7DBbOpOvAYP7/71z3sPuY/ioT5D75p91Wx EOg/w9uu0wFtWwfhZx49+7gfqVEdCFQ= X-Received: by 10.99.119.2 with SMTP id s2mr22215863pgc.399.1524631397043; Tue, 24 Apr 2018 21:43:17 -0700 (PDT) Received: from tuxbook-pro (104-188-17-28.lightspeed.sndgca.sbcglobal.net. [104.188.17.28]) by smtp.gmail.com with ESMTPSA id c187sm29874766pfa.181.2018.04.24.21.43.15 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 24 Apr 2018 21:43:16 -0700 (PDT) Date: Tue, 24 Apr 2018 21:44:25 -0700 From: Bjorn Andersson To: Alex Elder 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 Message-ID: <20180425044425.GG2052@tuxbook-pro> References: <20180410222542.29474-1-elder@linaro.org> <20180410222542.29474-4-elder@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180410222542.29474-4-elder@linaro.org> User-Agent: Mutt/1.9.4 (2018-02-28) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.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 Reviewed-by: Bjorn Andersson 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 >