From patchwork Thu Apr 11 18:47:38 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Murphy X-Patchwork-Id: 10896691 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id AE7C31515 for ; Thu, 11 Apr 2019 18:50:35 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9376B28DCD for ; Thu, 11 Apr 2019 18:50:35 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 87C9F28DD1; Thu, 11 Apr 2019 18:50:35 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 37A7928DCD for ; Thu, 11 Apr 2019 18:50:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=d+V9YBt3FhFX4eO06BUU0ZvUws0j4ZSHHgdufjZGTHM=; b=OQqNSqYqD2J34qji9EUe7c/C4h fzhQOKi43Ac+wm5ZzG7ehhQ0Y8Pi7yZQPtIHVE5UmXwhe5ESAgD70S//oPJJ7AmRBugia0QZFGDfu rtHX8ZAld6Pg2m8+26+zOk8mlbPkT8NwtrIuXO7SZOcKTVSxiDYnMqKM/0J/tvvBordACYOZz5K8W a8n8pL3lEDj/eBNzGM1BJ44DhGsJ675Fbhgt0yq/Z3C5suqw6P08lC80+qD4bOU8RLW31K+izwXFn kQ7mH+0ZyElG9WwAz+wG00IH1xBpcb1xZkhZonZpW5pAZ+XValtgUf52mF0QQ6Yr23dn5rL5rvhpo o6hiTL4g==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1hEemK-000527-CW; Thu, 11 Apr 2019 18:50:28 +0000 Received: from merlin.infradead.org ([205.233.59.134]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1hEelQ-0002tB-5X for linux-arm-kernel@bombadil.infradead.org; Thu, 11 Apr 2019 18:49:32 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=merlin.20170209; h=References:In-Reply-To:Message-Id:Date: Subject:Cc:To:From:Sender:Reply-To:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=DMnZhta68iAX33CpRchMA+yMZHDHOGcPtQBVqQabrNw=; b=UD8Y6qB7WZHW/zSK2Do43pxGk jkGVNpY+vIMt7FOP07j9nG9BXQMEdIQAfvAQQv4qXHxL6vYnB+EOlLZBctRfBN9mru4BRA478HVjk NpCNGQWjs3uQhGrUs/trArizagA0S15K0ybkwPwHwsYQhdsVIDH5u12rUj6ZGD1VWqRzcvJqqZ5BI 0U2CHdCfCo0N6w6gr0I7othFcDVii9678C4k/ZJgGbyMxeBap/tvD8Yw20RHI1Vb0w2cNGGRSRrjG 2U/WWIl97xP/j3mwaqCRK6qC2JZ4ANdHtjhxPEUdy4NEa/okhR1zP0vm5yV9GzoJBaTyQvfvLi69b yQM08WjPQ==; Received: from mail-ed1-x541.google.com ([2a00:1450:4864:20::541]) by merlin.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1hEelN-0003dl-SJ for linux-arm-kernel@lists.infradead.org; Thu, 11 Apr 2019 18:49:30 +0000 Received: by mail-ed1-x541.google.com with SMTP id x14so6170547eds.1 for ; Thu, 11 Apr 2019 11:49:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=arista.com; s=googlenew; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=DMnZhta68iAX33CpRchMA+yMZHDHOGcPtQBVqQabrNw=; b=KrxWIEikxDdZvLu8UnFVjW0EcG/PU1SormZHDInUdtOAg+J8UeRfz2zXDqrYBYevOn JwyWhZgYwU6QtoPuE0mXZ1Oe5eYGnMUIagbCpUNbdwOBGj5GuTN3H7Op5ODJ3yxVBy4a HJv3vGEEQWldc4EKVLOm7+5le7P2BEiIWuDF1OhwdjSym2xlj9kWG98u6Ge2wHvP8QAZ tWipMQtzFYHT0eFwweBjtWhr2X29dn3Z6GXvM4PStsLb8BJAl2VsSyrgiCcO2JqfpiLQ mZIfb9bKl4Awxr45GpXcPVoobD3hUoYj2Adz7S2v77C2kyg4y/sYDgRpJl/SvI0brDXa u9JQ== 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=DMnZhta68iAX33CpRchMA+yMZHDHOGcPtQBVqQabrNw=; b=kf/FgUXGtk6QUg8AzdvVXWY1iHWtMVcU8KQGHG3oBCnTMd0vILVczNRrjBA8HBeDUK 6jzxhqyrL9M1pQilFryeGFZ10uc4FZrxnjNKtO6Aya33tzjoefWYn1kF62fafAXkDAeC ZzJRXh8YGtoQu1KvBEp9kc7MGcrXACmQgfwI5dPx89vzrBDS9BAAp3vreNzs7e+bAbPL rdz5/LtrGs2VTWyNTJKY1YCTDnwWUOXFr87B5G3B8iijYv5QCavh8QOO+RcQ1Ta4ZIL3 qU0Nf4k4Vwvyldrq7wiXS/3Tapsp5pz2Gs/JE7Qk6IdmsljiLVfjv4x/Zy0jjAfznpGn 3DmQ== X-Gm-Message-State: APjAAAVHHedBfaaBY5FXNZkK2tSerCj26fgZz1ljOKelx4goLVDYuetA Z3+oQfThfT30ZMxt+KJx9NmkDw== X-Google-Smtp-Source: APXvYqxGXfYCaCRlvVgksxX9b5Eab0yr+jZV0UQmnyepRxSCDJinf+ClgjALBi9ceksiejLlB/1QXw== X-Received: by 2002:a17:906:e285:: with SMTP id gg5mr27392064ejb.229.1555008568161; Thu, 11 Apr 2019 11:49:28 -0700 (PDT) Received: from localhost.localdomain ([80.233.32.123]) by smtp.gmail.com with ESMTPSA id b10sm1285130edi.28.2019.04.11.11.49.26 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 11 Apr 2019 11:49:27 -0700 (PDT) From: Tom Murphy To: iommu@lists.linux-foundation.org Subject: [PATCH 9/9] iommu/amd: Add allocated domain to global list earlier Date: Thu, 11 Apr 2019 19:47:38 +0100 Message-Id: <20190411184741.27540-10-tmurphy@arista.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190411184741.27540-1-tmurphy@arista.com> References: <20190411184741.27540-1-tmurphy@arista.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190411_144929_986199_AD250BE8 X-CRM114-Status: GOOD ( 16.04 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Heiko Stuebner , jamessewart@arista.com, Will Deacon , David Brown , Marek Szyprowski , linux-samsung-soc@vger.kernel.org, dima@arista.com, Joerg Roedel , Krzysztof Kozlowski , linux-rockchip@lists.infradead.org, Kukjin Kim , Andy Gross , Marc Zyngier , linux-arm-msm@vger.kernel.org, linux-mediatek@lists.infradead.org, Matthias Brugger , Thomas Gleixner , linux-arm-kernel@lists.infradead.org, Tom Murphy , linux-kernel@vger.kernel.org, murphyt7@tcd.ie, Rob Clark , Robin Murphy MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP dma_ops_domain_free() expects domain to be in a global list. Arguably, could be called before protection_domain_init(). Signed-off-by: Dmitry Safonov Signed-off-by: Tom Murphy --- drivers/iommu/amd_iommu.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/drivers/iommu/amd_iommu.c b/drivers/iommu/amd_iommu.c index 02b351834a3b..bfb021d656aa 100644 --- a/drivers/iommu/amd_iommu.c +++ b/drivers/iommu/amd_iommu.c @@ -1801,8 +1801,12 @@ static struct protection_domain *dma_ops_domain_alloc(void) if (!domain) return NULL; - if (protection_domain_init(domain)) - goto free_domain; + if (protection_domain_init(domain)) { + kfree(domain); + return NULL; + } + + add_domain_to_list(domain); domain->mode = PAGE_MODE_3_LEVEL; domain->pt_root = (void *)get_zeroed_page(GFP_KERNEL); @@ -1824,8 +1828,6 @@ static struct protection_domain *dma_ops_domain_alloc(void) /* Initialize reserved ranges */ iommu_dma_copy_reserved_iova(&reserved_iova_ranges, &domain->domain); - add_domain_to_list(domain); - return domain; free_cookie: