Received: by 10.192.165.156 with SMTP id m28csp78926imm; Tue, 10 Apr 2018 16:51:14 -0700 (PDT) X-Google-Smtp-Source: AIpwx4+o2XjkB1yjwXPxVvIuSJ/f0nlOE+W49cURyly7B3bZrfj3gsHgJWsSGyjjLGqo0jPaBr58 X-Received: by 2002:a17:902:5581:: with SMTP id g1-v6mr2493831pli.351.1523404274572; Tue, 10 Apr 2018 16:51:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523404274; cv=none; d=google.com; s=arc-20160816; b=eT/lTM3Fb0vDPWRIgvRjZhWfPkZBujRa35KSKxqi6KghnrL2LhOUaCEO8awzieTN96 UNgf/4nrw7OoK+fr7RSWKLPFKZEkr65aFEoaZQbw/SYO7ynHrXcgOG4Vx3lgiXVoYsg/ ZmMPjTT1yPEi+neEeyMLA4bPmqnc+PaShK4Gc99jhNFVAAhOO7oZ1aJyUEeWRY8FLAJM v2ntGhJb1pL9JC/Y0EJdqIAbZXNd3rHBaLc08tm5fu2l/wTYt5S3Xa/qVRmyUr0NjhQO ynxun9UJDM2Jvwok0ehOaUpSWQMRbBOZZcuj2qGpp7uRFTVFqn4uZWWittCHpmpTV5ey 4gtQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=l3H4/EZviulqejooLx4wkjMJzF09A09A4x/ztGcOCwk=; b=dKWZk+hksekxRCEaGVsgfoxBFJfL3OVNM4MT9YGxsdvgsH8vDhkvMdd30JeZQeiHe/ ax9J+TFwlQYzjp0BoAgcOYd2nARh+HiyBno8eW7Fd2zpV4NxDcql9rJcLQ1QDSfWaqWh dzJv6oNrnFo7WH3HyiilIvhdlMxo+G1cE91+eZ7LYGOFYXBJiBaIHuIF6Qm5TffMkl5B 38Dq5ONVmGB01YEeIp4bQU3mMPZA8bWpKP+NBooNEuxOjpdV9PL8G1cXIvRcdMRyM7Am GAjf/U9ckwCJk6Rb3oSSC42tCclCNaOOBjH+uXhTax8FG28tyRMzyRvDT41/qml2mnLE D1/A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=EclcHV8m; 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 n22-v6si3199174plp.561.2018.04.10.16.50.37; Tue, 10 Apr 2018 16:51:14 -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=EclcHV8m; 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 S1754594AbeDJXnI (ORCPT + 99 others); Tue, 10 Apr 2018 19:43:08 -0400 Received: from mail-it0-f66.google.com ([209.85.214.66]:54123 "EHLO mail-it0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752988AbeDJW0J (ORCPT ); Tue, 10 Apr 2018 18:26:09 -0400 Received: by mail-it0-f66.google.com with SMTP id m134-v6so271219itb.3 for ; Tue, 10 Apr 2018 15:26:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=l3H4/EZviulqejooLx4wkjMJzF09A09A4x/ztGcOCwk=; b=EclcHV8m006CStuIV5DfTqqY/k9qOmyHKUWqEWEtVyAo6ZZY8fDQLFuU8eCRWpoKQ7 11K8UIz6DNTOBhJn+PLsxV4Pi21yWMLlZYjnJhskKsNQg03l/nv78IlB+2heJQEXyrju /kS/CQEhJRtzmK5VOyYzcrp0KozrlT0VyUqZo= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=l3H4/EZviulqejooLx4wkjMJzF09A09A4x/ztGcOCwk=; b=XFUMnqgklLI/meNKHSfG2Y7r6BfZsLQ7P/bggACUv+7xlsyFvVv6VD5sXj9fBzTLuJ bDHLIuwxlnLxWjbU4loW14tuZtk48h/LnJ+VULph7s5l9MbWeIx3AZtiqY7G+BcpOA6Z tL/jBAQMIsjGJXteO8tYP+xMzLkwaPzE1pYdJEWPEGr+YxoeDr2fkAQbm2IcPG2slJMw eWpnVJ648pdou7NmsI0l0GjmRy+hi5ez9Hb5R5T1mdHgiWgfqikv1mXlIF2OxObO5hkZ NlKj+314zR6GOBU/f1DzOyS55Nu9RZVhPT4ZcnxJV8weY6/yMewhVCruQXZxQnfd2Wv7 G/NA== X-Gm-Message-State: ALQs6tCRSUOOT1wG0Sn2v4iYscX96tkeO2CaH0bwp0PeAoD+fCjGaDOj tTi7ofMjYPiViqvMq6gtWz0nnfKNEo8= X-Received: by 2002:a24:c2c7:: with SMTP id i190-v6mr1437363itg.146.1523399168805; Tue, 10 Apr 2018 15:26:08 -0700 (PDT) Received: from localhost.localdomain (c-71-195-29-92.hsd1.mn.comcast.net. [71.195.29.92]) by smtp.gmail.com with ESMTPSA id l16-v6sm1373640iti.18.2018.04.10.15.26.07 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 10 Apr 2018 15:26:08 -0700 (PDT) From: Alex Elder 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 3/6] soc: qcom: smem: byte swap values properly Date: Tue, 10 Apr 2018 17:25:39 -0500 Message-Id: <20180410222542.29474-4-elder@linaro.org> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20180410222542.29474-1-elder@linaro.org> References: <20180410222542.29474-1-elder@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- 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