Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp305920pxb; Wed, 20 Jan 2021 07:28:55 -0800 (PST) X-Google-Smtp-Source: ABdhPJyHY593KaiLuS0J+PfMANoNCNjTzn0A4CN3cAg3nKRtGbT0dDrxI4odXURJT5smikrBsQv5 X-Received: by 2002:aa7:d148:: with SMTP id r8mr7722028edo.127.1611156535732; Wed, 20 Jan 2021 07:28:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1611156535; cv=none; d=google.com; s=arc-20160816; b=uLJadiX2qJjzM7DByXKBtPZHrC4wkkuKF9ZhcSz2qw0C9dXW/ub/GO7Uio14AKA4OX /jua0ZHP5rb24lh7AOR135ozApr/4LdxreGxmqeBK+JVFUex46WvGiBMscjJyh0rq93E dXA3eJ4B5Ty6K7Ohu+rTlAuby2nmJjSyoPlYbvhPyIcKzk6DjXHX4Cx9T/1fUB3BQhZ2 dHy//SkOM4GFKezbEHchP6+5E2eutvGhPN4gyu+UImVpGsKJSOwoClwQjfUC54P+XsU4 0BoeMD9eYrNBL0KI6YTl0E7SqwWxelsFex0FVO0sejaygDwnup6SBDKEzSlHgtWuoK1T XgkQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=scySoWq6Kv2tIYE/jnpMXwy39fvPiWP6qekADHBvytg=; b=QuOtX41K8AhHMFpuXahbIYvkbx9x0zVeAZb67rhZ12bN5doGL6irCyltzApcDKcPp9 7Mq7+1tcK5lZhlIdkLMTW8PbH5DJFn68GjLg9Jpp3DddfuVLt5AplCfqTOp32qT+udM/ 46l7Lz7ikAbPKMrdPtfT0gttw4G1KWwCdbPvOpe1B8lRKWvHJzigMG1esexlbDrtuk7q f2C1IQn8dut3DTyev+flUuxojSzh5hAK4c3C5KOLvmr3iEFTO/exlDIR3smgAH+Tzzn9 7Dbfri5tGyVBMInBVXDpDlnLVQnBqtRIgxf1xiIfzewPj2PKwqCM/AAlWNm5wmiWWQYE KqGQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="IEV6/G7g"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id e10si943139edv.269.2021.01.20.07.28.31; Wed, 20 Jan 2021 07:28:55 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="IEV6/G7g"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2403957AbhATP0r (ORCPT + 99 others); Wed, 20 Jan 2021 10:26:47 -0500 Received: from mail.kernel.org ([198.145.29.99]:51504 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2391005AbhATPVF (ORCPT ); Wed, 20 Jan 2021 10:21:05 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 82BC6233A2; Wed, 20 Jan 2021 15:20:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1611156023; bh=r0M1Ka3u8aAoDgdxe4IPOf2mDljJGtGVJIj19ojD0O0=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=IEV6/G7g4viv0Q8HAPyCI5d7SyPurUG8zU26qpS1QoLPKM4mlgstAjiGh6srwDgc3 OtqNVZnQKvJv8zNcaQ+m9+pCm5pYU2HgtERGL9OZ5eU1ChhQfa88T9H0TsBThLSkI/ IVzaYWdEpunUf0Eb9tmvDjPYw6cvTwtdNoSaDY95d8b/ltqTkZVJzwOpNBc2uWloke r9AwYynXKcmRY+q6bitd+ZJyoFdSMwOW1MggN/jY6V4cR40iylWBOAeHOd7qhlSMgp 58KOue6NvVd4f9HGWI+G9CjSQfVzdb3E+g7ef5RTSmwOwJ+QPyPq3BTQSjZ2LwljHP T/cVX0FtxzEWw== Received: by mail-ej1-f44.google.com with SMTP id ox12so9743593ejb.2; Wed, 20 Jan 2021 07:20:23 -0800 (PST) X-Gm-Message-State: AOAM532m5mUW+BH5TfQP8RboKrnzmMEstVi0BwycGigYRSN1w7CX7Dfj IAx6P46+LSs1BO1uQiiNMeLaD8LCtLMCPYdk/g== X-Received: by 2002:a17:906:ce49:: with SMTP id se9mr6530993ejb.341.1611156021968; Wed, 20 Jan 2021 07:20:21 -0800 (PST) MIME-Version: 1.0 References: <1611011439-29881-1-git-send-email-hayashi.kunihiko@socionext.com> In-Reply-To: <1611011439-29881-1-git-send-email-hayashi.kunihiko@socionext.com> From: Rob Herring Date: Wed, 20 Jan 2021 09:20:07 -0600 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v2] PCI: designware-ep: Fix the reference to pci->num_{ib,ob}_windows before setting To: Kunihiko Hayashi Cc: Jingoo Han , Gustavo Pimentel , Lorenzo Pieralisi , Bjorn Helgaas , PCI , "linux-kernel@vger.kernel.org" , Jassi Brar , Masami Hiramatsu Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Jan 18, 2021 at 5:10 PM Kunihiko Hayashi wrote: > > The commit 281f1f99cf3a ("PCI: dwc: Detect number of iATU windows") gets > the values of pci->num_ib_windows and pci->num_ob_windows from iATU > registers instead of DT properties in dw_pcie_iatu_detect_regions*() or its > unroll version. > > However, before the values are set, the allocations in dw_pcie_ep_init() > refer them to determine the sizes of window_map. As a result, null pointer > dereference exception will occur when linking the EP function and the > controller. > > # ln -s functions/pci_epf_test/test controllers/66000000.pcie-ep/ > Unable to handle kernel NULL pointer dereference at virtual address > 0000000000000010 > > The call trace is as follows: > > Call trace: > _find_next_bit.constprop.1+0xc/0x88 > dw_pcie_ep_set_bar+0x78/0x1f8 > pci_epc_set_bar+0x9c/0xe8 > pci_epf_test_core_init+0xe8/0x220 > pci_epf_test_bind+0x1e0/0x378 > pci_epf_bind+0x54/0xb0 > pci_epc_epf_link+0x58/0x80 > configfs_symlink+0x1c0/0x570 > vfs_symlink+0xdc/0x198 > do_symlinkat+0xa0/0x110 > __arm64_sys_symlinkat+0x28/0x38 > el0_svc_common+0x84/0x1a0 > do_el0_svc+0x38/0x88 > el0_svc+0x1c/0x28 > el0_sync_handler+0x88/0xb0 > el0_sync+0x140/0x180 > > The pci->num_{ib,ob}_windows should be referenced after they are set by > dw_pcie_iatu_detect_regions*() called from dw_pcie_setup(). > > Cc: Rob Herring > Fixes: 281f1f99cf3a ("PCI: dwc: Detect number of iATU windows") > Signed-off-by: Kunihiko Hayashi > --- > drivers/pci/controller/dwc/pcie-designware-ep.c | 41 ++++++++++++------------- > 1 file changed, 20 insertions(+), 21 deletions(-) Reviewed-by: Rob Herring