From patchwork Wed May 2 01:10:10 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 134802 Delivered-To: patch@linaro.org Received: by 10.46.151.6 with SMTP id r6csp123890lji; Tue, 1 May 2018 18:10:41 -0700 (PDT) X-Google-Smtp-Source: AB8JxZpi3bBwmAYcQNV0Kx7dYjubIeR3cREzqyaFh4nOq2WYlurAsDppmp0uz396B9S9mE/FbIAw X-Received: by 2002:a63:b306:: with SMTP id i6-v6mr14488527pgf.434.1525223441376; Tue, 01 May 2018 18:10:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525223441; cv=none; d=google.com; s=arc-20160816; b=G9t2tj2RTQT2TDkq5ByaBZ13E0Bhm7mlQ3yu3oxMWw2B2/dfrm7Ffi6OZW5LnR/0JR +NECeSbHFLP0BgmJ742iS0vguR9N0J5biVk2GB4d8F1DsDjqHGTiQpvjhgmExLqhJzvQ DXtIpoRRovKbrFS7JDJeg4WE/33UqooEVr7A7Yw1B8DycSJyUZVIM0uJN5xFUNgWP6KE gNbL4QhRywVKmMo5AZNcq0qTaNwcQTwhG5osU2AXAJ+3/xLZQWhNXHmEj+VYIQMST7g9 wgM14Q/vwrZRBA/8kxcXfS+Ufx5zDG/wrWn5lJkB2njqB4tFHgwXsWU84Pin/lMdESS9 XK3g== 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=kq6CRR13g0ZQDxfwlHNYxxG+y+NU/bsxsrEwj27VIMM=; b=rX1UnxpULN7ZZ3pl91R8dPkSO2aIpBlQ6GcohoUleidMbU63mx07vcruGqJXymREuk 5XPOYNw4LQ6qbzeic5LFxYQuu1VK1sM0DwoxmZqJCE4OyBRXczYR/VMoHxoFelMw0zwf /4rxrQ0ocye3SpnJAF7g4wrkTkV0UGz0UCrMqiMx1Y0+tcfc1DDYd0K76+COqCFeWjm2 eLAVq4ZUvM694Lei0M4qHAEa7VV/GMvf9/cgxkWD+oV3p3OmJI2GgMZe6aikNXPE3D/c 115mqqZBkQt76rLRaoPG3S2BRhhObWfgHYrVJZDM9sufVrwMSF/SI3CBkeRttaC4wdWf KDGQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=a3V2Pnt8; 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 b9-v6si3718178pgu.27.2018.05.01.18.10.41; Tue, 01 May 2018 18:10:41 -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=a3V2Pnt8; 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 S1751324AbeEBBKi (ORCPT + 29 others); Tue, 1 May 2018 21:10:38 -0400 Received: from mail-io0-f196.google.com ([209.85.223.196]:40212 "EHLO mail-io0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751174AbeEBBKb (ORCPT ); Tue, 1 May 2018 21:10:31 -0400 Received: by mail-io0-f196.google.com with SMTP id g14-v6so11899680ioc.7 for ; Tue, 01 May 2018 18:10:31 -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=kq6CRR13g0ZQDxfwlHNYxxG+y+NU/bsxsrEwj27VIMM=; b=a3V2Pnt8jbYM7T57T8o9IeX5v7VwHeev3soVnvqOYborpb9RNTuFw+ubLc/s7HpTQ2 XLJl1VvW8a1GbKeUum/DPh+A/FpX/ILnI6yrSW97oIxv/SwzE3/bnK1qmlr1kn7HdsZu x6SkIjinZRgzkJCwAbr2WUYrPcJl0XZyva14Y= 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=kq6CRR13g0ZQDxfwlHNYxxG+y+NU/bsxsrEwj27VIMM=; b=fKdJWmnyodAGMsEIMQHkuE78uwV6Es5yrjQlAauV2RrAkr4PMGJyYSocslzXKSuZf0 7ex8wS2lc5cDcUdo+fzYZlHxihlMXamkNzPcxiRQnx5X/2gDTwqIcp0+dJnGEd/+BeIY eRfiCNQjV2ZlPM7NAKTryoND17X3YjIoFNbpJ6y1rMo+QdyFTqLOx2XtJ0gRvmArAxNi pWDnBTigpeqMxb8YZdarog8OKPBMPfgOFWGD2um+l1YfMkzXGxiop8VR8ZZpmrlI8+Gi GpO8UfillHqRZFMFDjSB7tyAlFezGfjFjxVcjUjtElAUOWiDmOozOXB/rgwJbIOq4zos KT+Q== X-Gm-Message-State: ALQs6tAyeG3o2sILyxHVHREc2Gu0lEYZwsKXxCRMxPozx2r1E8GM6K5z 3Gpr4Y0dY1bTLaNZtNjYpGtbWQ== X-Received: by 2002:a6b:d404:: with SMTP id l4-v6mr19011070iog.37.1525223430686; Tue, 01 May 2018 18:10:30 -0700 (PDT) Received: from presto.localdomain (c-71-195-29-92.hsd1.mn.comcast.net. [71.195.29.92]) by smtp.gmail.com with ESMTPSA id g200-v6sm2082479itb.26.2018.05.01.18.10.29 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 01 May 2018 18:10:30 -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 03/12] soc: qcom: smem: always ignore partitions with 0 offset or size Date: Tue, 1 May 2018 20:10:10 -0500 Message-Id: <20180502011019.22812-4-elder@linaro.org> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20180502011019.22812-1-elder@linaro.org> References: <20180502011019.22812-1-elder@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In qcom_smem_enumerate_partitions(), any partition table entry having a zero offset or size field is ignored. Move those checks earlier in the loop, because there's no sense in examining the host fields for those entries. Add the same checks in qcom_smem_set_global_partition(), so the scan for the global partition skips over these invalid entries. This allows a later check for zero size or offset once the global entry is found to be eliminated. Signed-off-by: Alex Elder --- drivers/soc/qcom/smem.c | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) -- 2.14.1 diff --git a/drivers/soc/qcom/smem.c b/drivers/soc/qcom/smem.c index d8008bf480a4..83ba549cfea0 100644 --- a/drivers/soc/qcom/smem.c +++ b/drivers/soc/qcom/smem.c @@ -742,9 +742,13 @@ static int qcom_smem_set_global_partition(struct qcom_smem *smem) for (i = 0; i < le32_to_cpu(ptable->num_entries); i++) { entry = &ptable->entry[i]; + if (!le32_to_cpu(entry->offset)) + continue; + if (!le32_to_cpu(entry->size)) + continue; + host0 = le16_to_cpu(entry->host0); host1 = le16_to_cpu(entry->host1); - if (host0 == SMEM_GLOBAL_HOST && host0 == host1) { found = true; break; @@ -756,11 +760,6 @@ static int qcom_smem_set_global_partition(struct qcom_smem *smem) return -EINVAL; } - if (!le32_to_cpu(entry->offset) || !le32_to_cpu(entry->size)) { - dev_err(smem->dev, "Invalid entry for global partition\n"); - return -EINVAL; - } - header = smem->regions[0].virt_base + le32_to_cpu(entry->offset); host0 = le16_to_cpu(header->host0); host1 = le16_to_cpu(header->host1); @@ -809,18 +808,16 @@ static int qcom_smem_enumerate_partitions(struct qcom_smem *smem, for (i = 0; i < le32_to_cpu(ptable->num_entries); i++) { entry = &ptable->entry[i]; + if (!le32_to_cpu(entry->offset)) + continue; + if (!le32_to_cpu(entry->size)) + continue; + host0 = le16_to_cpu(entry->host0); host1 = le16_to_cpu(entry->host1); - if (host0 != local_host && host1 != local_host) continue; - if (!le32_to_cpu(entry->offset)) - continue; - - if (!le32_to_cpu(entry->size)) - continue; - if (host0 == local_host) remote_host = host1; else