From patchwork Tue Jun 26 00:58:47 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 139905 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp4617416lji; Mon, 25 Jun 2018 18:01:25 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJYQbiAp++LQom4ghSXJS9MJ2choZefIva1I69DMfUqNvBte2MhD17d53Y+VhCzrtjzZt70 X-Received: by 2002:a65:510c:: with SMTP id f12-v6mr12170802pgq.288.1529974885258; Mon, 25 Jun 2018 18:01:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529974885; cv=none; d=google.com; s=arc-20160816; b=y1Vd8gNbX20fsA9jp1C3Oi+53nYnXKuLh/xi2A11Mr0mhhzGnKIqgXjs+vdjRqWnci wFNaq/BfpIT1ffrDFEc13J59v/z1lo3LoTsgdZQuehQhLXARAIhAISTnMxhjHr4OzKYs 76oSo4Gotlt+o1DSq2hM0CFNq+M/2CUMyMiB6B2XzBqGHXAGQTPBf5Yz8hHp0AUhslzY KbTfbFELQnQmzl/sah3luGoHo09L6xWCpI87Wf0TPXLp8M9XDjZ9nEWFbHG9n61n6PYz umq0eLF6pLc7Qt5kSQVyy4Qh0iErBTu2ve4T8RKJ2dAQj1YzZk6Uf36oeACAqNfs/UHn 6XDQ== 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=XA/E3QTALeKtLrl2UKl+cued+8oFK5Fk+61ksYnsJDA=; b=BRFs3eZ+MigL1hjWymwErLi7MK/7+NMlHe0ISuhDKG5puJHQ5JRVZpOiMFYgtp4sHd OU+1ExZ0DZIl7I+HlaSscBkkcevBi+ggibebgR6jRIeDaNr5B+lhvvNwaPPFH/7BnUHi frD8irYzh0MAZ/G9kr95Yw2np5ASvGTe2et/b4BEXW1R+1LKfFNJu7jqVprVavdxQIN1 Cqy7k+TOrufmDzHwPZ8eMbuyxL7w7dXGqugJSZFd/BZRwcgMmsPoOm3a9h5hpeqZddRz RiDsgkQqq3WY1g8nbFu+0qIaLYZvbq4omo9n6998HDRRcIegIQlEokhuYZmk+sKFHxBn w/QA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=O+rMum1z; 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 r17-v6si297537pgd.52.2018.06.25.18.01.24; Mon, 25 Jun 2018 18:01: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=O+rMum1z; 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 S935249AbeFZBBX (ORCPT + 31 others); Mon, 25 Jun 2018 21:01:23 -0400 Received: from mail-io0-f195.google.com ([209.85.223.195]:32891 "EHLO mail-io0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755789AbeFZA7E (ORCPT ); Mon, 25 Jun 2018 20:59:04 -0400 Received: by mail-io0-f195.google.com with SMTP id d185-v6so14331451ioe.0 for ; Mon, 25 Jun 2018 17:59:04 -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=XA/E3QTALeKtLrl2UKl+cued+8oFK5Fk+61ksYnsJDA=; b=O+rMum1zamoWjUYs2wfTqNzfawRpjRbLU17yyjd6Nvl9aMiSNZMcr7W0y1EbC4DU3Q Ho0qI5xbHJFolESzOSB0C3PWF63FufIZwUBo+L9w3Nj4Cp9RytkoH18045hg2tJx2BeK j0fmRCr770eW9l1kLkIXA1BI6cXP1TSDXrp3E= 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=XA/E3QTALeKtLrl2UKl+cued+8oFK5Fk+61ksYnsJDA=; b=csLzOAeyU5Sy6Dhg2RhlIkAs5N7tPtoG8E+VW//d65bigqlsAfNFXw7Lp3UipRu/IB A9seyOVsTq7+Hug4bhi1jPnZQIMCOAJ/D0Dyb6kxAQI6CnjGxYRZtLou0+VSpwjyd1pB z37JkwZegj+lD/GZCpiliXoVf7ndpHGSZdCqZjvxvPrmrVFI7zus75gomXd+pdqrSnqP hb8/HZKu1Ng1PMtMWDimvPvDBeKwHdKc0H0JlE+iawevlv9R47Psf97VvtSqAHcpjrqS 7byb1Dgtu1xG7jonjq83C28uwtlALqQNuporbURmwf1tD2V7wFm5u/BxRzaEM9DxC/W4 3/HA== X-Gm-Message-State: APt69E0HoUFSIm8cCSVqrED1mlEPnLX4SCSMOGfqEmE5u76kHn7/PvKh RryJnQQnwd4OmtpZ5HSqSUal6Q== X-Received: by 2002:a6b:9fcb:: with SMTP id i194-v6mr9879060ioe.286.1529974744327; Mon, 25 Jun 2018 17:59:04 -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 f193-v6sm372556itf.9.2018.06.25.17.59.03 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 25 Jun 2018 17:59:03 -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 resend 03/12] soc: qcom: smem: always ignore partitions with 0 offset or size Date: Mon, 25 Jun 2018 19:58:47 -0500 Message-Id: <20180626005856.14174-4-elder@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180626005856.14174-1-elder@linaro.org> References: <20180626005856.14174-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.17.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