Received: by 10.192.165.156 with SMTP id m28csp76307imm; Tue, 10 Apr 2018 16:47:25 -0700 (PDT) X-Google-Smtp-Source: AIpwx48B976WSalweZoGmh3lEykh+boBHJH9vJBi2cyVDcsmdCz+10Q6L+OF/wbdAJ4D54KTOrQy X-Received: by 10.99.95.5 with SMTP id t5mr1680908pgb.295.1523404045140; Tue, 10 Apr 2018 16:47:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523404045; cv=none; d=google.com; s=arc-20160816; b=vPuDVJ4gTmjBXaKfSAEll1kxTFyJCvSiGL8bv8IC7XZg3FipeBbGb4X9RHwh/wccSl GuQqPJGQ0Ay8UBRPFdGOcWaaHkiF/J8ws4QefHrZOUYiQbAtuAz4nt4iqSCqdlVRfqG9 VV6kf0v+3FCLFEJxmfhtIlUp+YrKQgw2Ek6I4M+jmotzu3DR7ldLRAT7XaEhOe4dYoge ocyxzOCJzBgykFsoRqasyDjD3S21zl8J1Lql3lm1xgH5N0T1lpgmg+lnS++AYU9eZqcc 0OEQNponwQztDhbcKCosYgD1DXEUnaX6FCYH7Jy9O5ZVZ6AZQhCnMwURIR0tqLxo4diX izVA== 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=H9qmvqAiJ/VbTfERmUNt70MGbbyuK6OGOtSlbgP2vA0=; b=R2aYv/2na3Erx1GA1wotkN2Sfx4EWnsYARTJj6EPQl+fK+NJyJ+Xd9LGpGazlIrq90 tnTXSJgoR0v58D1HKrVC9dQrCjgXapI2VEbcKz8T/q/ptIoZSEyuZFPsF9CmOhXvMlhE h/PyvXzZXlXsJeJn37fd0zjOqV6fpjQ4AFw0hHxXtelQk6ZyhE2tXmTZn3gMeHlEZocl NoMx/UZLS94/XOF5iiKwtTHxANZOix3Tj2RjyOMvPmx7ps2p8UBLnjfOD5by2P6r65Mj ILsKe4D2cPhm99JM4a1AgMCaWett1j1XO2BNVGVKRe5HDZbEYp9tk1WGkof7WIw/CiZf Aiuw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=fyciM/YE; 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 r7-v6si3798991plo.486.2018.04.10.16.46.48; Tue, 10 Apr 2018 16:47:25 -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=fyciM/YE; 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 S1754372AbeDJXm1 (ORCPT + 99 others); Tue, 10 Apr 2018 19:42:27 -0400 Received: from mail-io0-f194.google.com ([209.85.223.194]:42431 "EHLO mail-io0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753041AbeDJW0L (ORCPT ); Tue, 10 Apr 2018 18:26:11 -0400 Received: by mail-io0-f194.google.com with SMTP id d5so217048iob.9 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=Q/SGVjPZt8XmGxLktb7B+Sd2Y68pG4H0uxzVwplw0k+0/yJnIdm3fY8Oh6AhVEoJBD SkUlwqkCjC4ZVdUWRghkXGdppm+vOlLGWmmqo4WQhDMayd3ugNYc9lyeOouVp++mb7Kc 0VSUXzr3738wxtDoCD1cyPVxr8vSTxXZ4A+JekKm1IrCyzFIsut3IdmuwcRTVAuTWPoC tVdv/fmrER3qOcHWboDI61hvIBCgPcOODxyE1SofXV0ox370+Q2juxjevfkRIMlIaut6 5QfGvqvuHbm+4Sz0CUtuN1fWyP1bRbvLUUyf03moHHvhmb49S8bwfE+Tphpt8DvSD5PG qE5Q== X-Gm-Message-State: ALQs6tBwssc7uE3ZmYtrzTpvILIXaZEYPbpWf7nQz6QaDZ75GCCDYZGi Zm8beQsK5X5hUbA3E923o+CNhQ== 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-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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(-) 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