From patchwork Thu Jan 10 13:49:06 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Loic Pallardy X-Patchwork-Id: 155163 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp1915962jaa; Thu, 10 Jan 2019 05:49:43 -0800 (PST) X-Google-Smtp-Source: ALg8bN7ggE4CFmcqnHzQuYJwjm+tfuoxowSaojcudUQlT20nVb+Hen44PkLr2frcIy23JUWliF8y X-Received: by 2002:a62:345:: with SMTP id 66mr10217194pfd.189.1547128183838; Thu, 10 Jan 2019 05:49:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547128183; cv=none; d=google.com; s=arc-20160816; b=t+xMeTzpsaNfVNDgw9xeD74jByqiqG3YhzeF6LiTvLHqMJx7SeB0DfwSNPSTZPcE2e wbY5lXVJXjj3jxQxnn8e6dxBn3mQP/X5LVUnaLu7ZoyYaF9Nc2T7m3ybroTnb+x/K72M IDN4XpVLHwenPwBB2RKLdrrU9cxREL0e98Uqt44nmgki7X4XfIE+SYS/GhkO/SI/ZEPy gH4NJEjAqtWlEIZkMPejit4ytJ/lI9rHaKXxkcbyoHcs9i1jDp0F/hMVKhfCsHjjbcaC YMZr8K8C1f/pdlny5kbJ73Gmnx4sEPazTJOUM25D96l9XqFUtaSemMqZGSTRUdLZ8TWe vdpg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from; bh=yunOxm7f641ArikQSrc8dqmBdmRcvehu5Wg1kzPhb0o=; b=bCR7wI0P+a8z5qFBbykKKqnRp7b/62It0U1KLRyIP2qycnpOx+2u2s0w03UrXwDo88 CW+5TqZs9F9GDNkiFwi5j6ICt4C+zolSsBkHZb+AWGKCEQM06tk2iuCftnnxszYZuonU pJtMFUP+gH0DG6TbhO4/5hHYFbY6GUtgEj9mKNDJP69wGJqkoq7xJuTQ2l6STAD8gc1B 3w3YTPM665aEtFV2th6Qo1LknuM7rUQapFHbevARberZAdXLHNjI/0KmBjULS+B1hgZR 2UKSHiB3GASxqGVHbgs0WEsEj4hsWexRXcaQej6Rhi5MChNzn0ET1lbQJQnxoSPM31eI xs9w== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x8si9294437plo.259.2019.01.10.05.49.43; Thu, 10 Jan 2019 05:49:43 -0800 (PST) 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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729080AbfAJNtb (ORCPT + 31 others); Thu, 10 Jan 2019 08:49:31 -0500 Received: from mx08-00178001.pphosted.com ([91.207.212.93]:45158 "EHLO mx07-00178001.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1729010AbfAJNt1 (ORCPT ); Thu, 10 Jan 2019 08:49:27 -0500 Received: from pps.filterd (m0046661.ppops.net [127.0.0.1]) by mx08-00178001.pphosted.com (8.16.0.27/8.16.0.27) with SMTP id x0ADf3oF008201; Thu, 10 Jan 2019 14:49:22 +0100 Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx08-00178001.pphosted.com with ESMTP id 2ptvjg2ptn-1 (version=TLSv1 cipher=ECDHE-RSA-AES256-SHA bits=256 verify=NOT); Thu, 10 Jan 2019 14:49:22 +0100 Received: from zeta.dmz-eu.st.com (zeta.dmz-eu.st.com [164.129.230.9]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id AA93234; Thu, 10 Jan 2019 13:49:21 +0000 (GMT) Received: from Webmail-eu.st.com (Safex1hubcas22.st.com [10.75.90.92]) by zeta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 8A08A504C; Thu, 10 Jan 2019 13:49:21 +0000 (GMT) Received: from SAFEX1HUBCAS21.st.com (10.75.90.45) by Safex1hubcas22.st.com (10.75.90.92) with Microsoft SMTP Server (TLS) id 14.3.361.1; Thu, 10 Jan 2019 14:49:21 +0100 Received: from localhost (10.201.20.178) by Webmail-ga.st.com (10.75.90.48) with Microsoft SMTP Server (TLS) id 14.3.361.1; Thu, 10 Jan 2019 14:49:20 +0100 From: Loic Pallardy To: , CC: , , , , , Loic Pallardy Subject: [PATCH v2 2/7] remoteproc: fix rproc_da_to_va in case of unallocated carveout Date: Thu, 10 Jan 2019 14:49:06 +0100 Message-ID: <1547128151-44077-3-git-send-email-loic.pallardy@st.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1547128151-44077-1-git-send-email-loic.pallardy@st.com> References: <1547128151-44077-1-git-send-email-loic.pallardy@st.com> MIME-Version: 1.0 X-Originating-IP: [10.201.20.178] X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:, , definitions=2019-01-10_05:, , signatures=0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org With introduction of rproc_alloc_registered_carveouts() which delays carveout allocation just before the start of the remote processor, rproc_da_to_va() could be called before all carveouts are allocated. This patch adds a check in rproc_da_to_va() to return NULL if carveout is not allocated. Fixes: d7c51706d095 ("remoteproc: add alloc ops in rproc_mem_entry struct") Signed-off-by: Loic Pallardy --- drivers/remoteproc/remoteproc_core.c | 4 ++++ 1 file changed, 4 insertions(+) -- 2.7.4 diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c index c1a66e25b173..28df71cb3fef 100644 --- a/drivers/remoteproc/remoteproc_core.c +++ b/drivers/remoteproc/remoteproc_core.c @@ -204,6 +204,10 @@ void *rproc_da_to_va(struct rproc *rproc, u64 da, int len) list_for_each_entry(carveout, &rproc->carveouts, node) { int offset = da - carveout->da; + /* Verify that carveout is allocated */ + if (!carveout->va) + continue; + /* try next carveout if da is too small */ if (offset < 0) continue;