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: 10896707 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 04FA317E0 for ; Thu, 11 Apr 2019 19:04:51 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DD3F628A8B for ; Thu, 11 Apr 2019 19:04:50 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CF9F528AF5; Thu, 11 Apr 2019 19:04:50 +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=unavailable 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 6DACC28A8B for ; Thu, 11 Apr 2019 19:04:50 +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=HKBoC7uag9xbaebouOOkLrTWoJ99Xgkekjc7XhFLahI=; b=a7ZKLtcfba0+y3rRJUHyaEE2GU T3XSiAlvPLQcIcvF3ksPUhQc3RyEOOg6hnFr2G9FfqsYwgSEv28lHv2ug0rq0HYggSHPhW4iC8qp6 Ni3XGuFTZYv82wKA81TX+K3+Ly67hOppNFyo0B8jH/WspBx+QFvt0wbg7xwIEit4hQOP8zfvHi0NL nvGp6U5M0dbjIkfJ9Tu/JoWL6WGeStNopmCALhYOY2iF0w4Dvy/J69X5BF6bg9MF7UMxWjtCPCdxI xi0V2S1wyqt6HI6LRbVumbxshOA8tremkffDDsXPttBmzOg2es7G/z+4zRmJ35K1phYVNljhfVbcA Lwp2AzPg==; 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 1hEf0E-0002tL-3u; Thu, 11 Apr 2019 19:04:50 +0000 Received: from casper.infradead.org ([2001:8b0:10b:1236::1]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1hEf0C-0002p2-2s for linux-mediatek@bombadil.infradead.org; Thu, 11 Apr 2019 19:04:48 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.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=UFMM2R1+JblMjzsLXetsDQfo9 LL6ERKawWZc23UCByZogAemiFBgdCwb1dFt1qs+LXhPr+LtblIzJXB0RdEVvyLrlISg5abfjGNTCu +WDfweRyXYYzNhy42bMNWvq2cqeRkCZSDQqM9GyhNmm1PEj72NbLmcN/v5PIvR8MM4qmddLmv+I9B Tt4Jr63K+ut4at7dgpIBs3cEEzTavHPffi2YuTMKEh+KZwv2Wh1JYjVnP0Yqv8nd9wugu2CeL6UBX coiqzG6aOXOnkA4bj2MDqYLVwWwgM2bD5FaBGXKsNYWZtfgD1+Bzznd5S9e6Shf2Ko2tvH4IPNW2I fAeOZKhiA==; Received: from mail-ed1-x541.google.com ([2a00:1450:4864:20::541]) by casper.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1hEelN-0006YO-Ch for linux-mediatek@lists.infradead.org; Thu, 11 Apr 2019 18:49:31 +0000 Received: by mail-ed1-x541.google.com with SMTP id k45so6142319edb.6 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=UlASYtTzpMQDJvR6w72ExoA0fMMaf4ZUPgtfo7hOw+Y42pYK8rs99h7yJyr7iPS60X Y43ehrYILbN5tnKCkFTugF4sfURSkRH5mSP8n4x4iMUJ+a2KbYEP679IHHsCAAwSocLh ZBRUK4aXSysbz9U88KVZmc/UyJh6VwQGzeoqsA41Lqyl8bpvvjd3Xytw0T5P8SpA1Zp6 kPju/KgKNOVBr2oNuD8bebCHtyBnwk60o0DpV7a1sOEncNUtYEFFSk1oZSU9K9ZoAdPk u6WFQtG/2bxJEzOqV0+IY8VC6TxfvOkwPBhJeWfHnAEBoHT/T/g1luQLGNkhm/w6Z3r8 elTg== X-Gm-Message-State: APjAAAX3361JqfUhzalQI6uS+38yuBFJDPtSJR+734J7IcEEJOoSBSaX U1KyTt16ufKk0MDdWAi1rFsnnQ== 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_194929_491074_F3567D79 X-CRM114-Status: GOOD ( 14.64 ) X-BeenThere: linux-mediatek@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-mediatek" Errors-To: linux-mediatek-bounces+patchwork-linux-mediatek=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: