From patchwork Tue Apr 10 22:25:41 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 133123 Delivered-To: patch@linaro.org Received: by 10.46.84.29 with SMTP id i29csp89968ljb; Tue, 10 Apr 2018 16:42:15 -0700 (PDT) X-Google-Smtp-Source: AIpwx49fag1T0AA670S/WmyOK+4km1wzJyY39Hd5/D4axzVAM72LLBLLwgnZdk3fw/JFE/TiImxp X-Received: by 10.99.4.3 with SMTP id 3mr1690012pge.147.1523403735023; Tue, 10 Apr 2018 16:42:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523403735; cv=none; d=google.com; s=arc-20160816; b=fUsEaz4PSWVyvmdUhWPZg5Skpl3y4rCoKx6F3Fcy1sVVM7KABiucGI+DOiWGzwt6Ec 9cb1Eh0zV7ij8sOjghH5JajXG1LWvDte8w1Ibebhr9tfHeDkuyS8lqlQQyyNy9W0v+iZ a88p7s1NnHso2k5+4/Lyycv6nh6cwPoY+vbH/Zi/JeNm3QcSiTIvYS+85bDFHZN40hCu xS5VmKflw8KlX6ieM9bqDN90FBcSBLDMSq4oQ7GlqbTDA2CJrvb6WbXuDKMvDeDxnbc+ ZUjRlBO4MH5wh4vEfLPjpefbWQ0ict/GUcOpZ+D6sb82xJQojhTwCoMPVhUsShdfrLme Huiw== 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=danQRC4RDtwFvadGNiA7XF5hHqgKl+TcAT/z9JJ8r5g=; b=gfmhDwdV0aBm2bwpKJnN2S2gMopVmnkqLdjwaPTTsa07te5DonvsLS/6z3GEsuej9/ ueQrLHBYcdwm3FOOlG+yPZD85A1EHRPjYr3CQ84yP0U3G2JQ42RjkFQTJD02hMQJp0xE c+Naz6FVZ6DUlUaLHmJsUZPkRkY+tVj4sqkSkfwYiNYBRm7HAHeXpybPKpHn+HYaBe9S 7ou92oaOq2BsEB/s8vOrhObIjxCT9Kc/5SM5bzX9IAFKnxE/n3Z/Guou2jnkxYuS5WMh BBdMXyd/CFC/d6qAFbVqv7XDHHT5d6cWrF4RrJQtkC7fNhGlvHX4YY8y/446lEJy8ilC wipQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=fyciM/YE; spf=pass (google.com: best guess record for domain of linux-arm-msm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-arm-msm-owner@vger.kernel.org; dmarc=fail (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 z14si2500722pgc.401.2018.04.10.16.42.14; Tue, 10 Apr 2018 16:42:15 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-arm-msm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=fyciM/YE; spf=pass (google.com: best guess record for domain of linux-arm-msm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-arm-msm-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752982AbeDJXmM (ORCPT + 11 others); Tue, 10 Apr 2018 19:42:12 -0400 Received: from mail-io0-f195.google.com ([209.85.223.195]:39777 "EHLO mail-io0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752977AbeDJW0L (ORCPT ); Tue, 10 Apr 2018 18:26:11 -0400 Received: by mail-io0-f195.google.com with SMTP id v13so225095iob.6 for ; Tue, 10 Apr 2018 15:26:11 -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=H9qmvqAiJ/VbTfERmUNt70MGbbyuK6OGOtSlbgP2vA0=; b=fyciM/YEQNQCiJjfJtuucPJasZ4j6lI65d5vWNNu1Z1xy/BUF0kAjY+7jWMXtsukfW 9WgjfgkfR2GrCMLIcpTrogpmh9OrWFzMvZcWFAYukV9CP3xHCKjDb93uf5CTc5pn5s72 5abcRB6MGT8NVPjldDGtQL9tLFPmPlIB8k8m4= 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=H9qmvqAiJ/VbTfERmUNt70MGbbyuK6OGOtSlbgP2vA0=; b=a6RZMROMKOyJQnMTca+FC75Zh1PIFy7m/EBXsNJOTrK87tM0yL4q5b/tAOYF1qQAPc HI84td3kDlBd3N2U+1nie96CeLjiwDbr5eLv99A4c8VypR9xit2ISqwxBFbidl/m4yL9 QNNxpYQWackfDyNpiQ/2Yk4fuJtMhc80Ls7gaxD2p+BbOeYR2TNpzqNFjAF+n4XEA+RE 3wKSDRHMyvsF4Kj6Ena/wBAKsbuMekRrp8+19Nzbp91zt+iU0ydCqsvTFdoPge7/h78v QQxG/t/PMx1eHl3bEzKfZJpGnDPPFLu1ZAi6rDd3vif11w/lDl5chrdhI6YPlIldm6Wb F1tw== X-Gm-Message-State: ALQs6tBHf7fsaIoXB0zMFIx9NJ6BdWLWVe6slwMUYGjr2qKpQeBoAoLC NvUL8YF8gUThaMM1HKdv4f99xw== X-Received: by 10.107.184.198 with SMTP id i189mr2273764iof.228.1523399170615; Tue, 10 Apr 2018 15:26:10 -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.09 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 10 Apr 2018 15:26:10 -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 5/6] soc: qcom: smem: fix qcom_smem_set_global_partition() Date: Tue, 10 Apr 2018 17:25:41 -0500 Message-Id: <20180410222542.29474-6-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-arm-msm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.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 --- drivers/soc/qcom/smem.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) -- 2.14.1 -- To unsubscribe from this list: send the line "unsubscribe linux-arm-msm" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Reviewed-by: Bjorn Andersson 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; }