Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp17925912ybl; Thu, 2 Jan 2020 14:57:38 -0800 (PST) X-Google-Smtp-Source: APXvYqxYbOOuyd5Q0DbMql8B31eojBYQf6Yv2hFUDiNtI7nvrY7oND2caM9GXOuB+gy8+I9LY+0i X-Received: by 2002:a05:6830:18e9:: with SMTP id d9mr85191135otf.332.1578005858131; Thu, 02 Jan 2020 14:57:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1578005858; cv=none; d=google.com; s=arc-20160816; b=qCeoslduv5nS39ZhVnDSvehCAmz66VmVphmAABV5zkXyV4r9p5oTBuVSEDnzF8+oWV 95sY6+w7TgN9UBxd0FQovbs45Z0BRzzrlQNQ5s4+/DVzEjpeqM5makBBOgVizT1w3cDG 38YX3x7OwqW0Z68dYc/yNAYWDXhLpxzVNoLvU+DEDpPCLdh04UwPG4LYq6fhm3iDpeLL ca6QPvETQjuuhQ2rVPu+xIRy5GWTsW9vMoOFSBeEcr2aQ+N7IKh0Lg7K1XIPXx1UrIK/ ULVXLdHLaNh4bJ6lM9LMy++tWaSARqEvARUvud2HT8Wod8d+xWLirD/Lokr+YUk3rFY6 od5A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=r3KDvA9fANpf4jLNhshX1VQCEdRkvLNu1hcGa7bs7SA=; b=D7z0O8yKwY0cmjyoGkP9BXPEMxW/TXsWfVNJ9Gfo3Mny4W8rrq18R1dhsOsRiCP9Bv 48WkeqM/xFQQ6AHwku3rU8Lzpdys2Q8kOhApWqMof8RiRm5AUEscwf63IOzJmiki/s7h gE/vDU7b1UGno99Ynrs+MK22JIUAn+Aq8+rCt4C6BLkzFvnOiEiad2G9ulC5uX3KMF+Q ol9APw/c1Kg66OdegpTgBOYGIE+yejmZfDIgIfSg+VNjhML0swtMkU20x3BIAXoINlvH bubhcdRnUrRvSFkcRV9bkpXMv+lGj7cb1YoY653RdrrIMHSkmvmjcCTnAReApBmKIEDR mE6Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=JJ4zJKIS; 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 n8si26776930otr.102.2020.01.02.14.57.26; Thu, 02 Jan 2020 14:57:38 -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; dkim=pass header.i=@kernel.org header.s=default header.b=JJ4zJKIS; 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 S1728385AbgABWT1 (ORCPT + 99 others); Thu, 2 Jan 2020 17:19:27 -0500 Received: from mail.kernel.org ([198.145.29.99]:35500 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728579AbgABWTX (ORCPT ); Thu, 2 Jan 2020 17:19:23 -0500 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 3181D2253D; Thu, 2 Jan 2020 22:19:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1578003562; bh=kBs+PGhfDJoXp+X0PDY6anu/CdS5IPxlDl/7I/nC9Gc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=JJ4zJKISzQXgq/c4ezEoYfIY6MN41Y85gmYSrakBvjbrbpUB1p4ENku4WbMbRAvqh XUzPCwijd0VLk8CV8WRFzWR4Un4PVmzvKps1bKK18thcAYVp2f2p0Q4hb6P96HQJr+ ilPYOJfflNxCDREiW1w0fwONj3CE/xfqqd33X8sc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Ezequiel Garcia , Robin Murphy , Heiko Stuebner , Joerg Roedel , Sasha Levin Subject: [PATCH 4.19 006/114] iommu: rockchip: Free domain on .domain_free Date: Thu, 2 Jan 2020 23:06:18 +0100 Message-Id: <20200102220029.805232190@linuxfoundation.org> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200102220029.183913184@linuxfoundation.org> References: <20200102220029.183913184@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Ezequiel Garcia [ Upstream commit 42bb97b80f2e3bf592e3e99d109b67309aa1b30e ] IOMMU domain resource life is well-defined, managed by .domain_alloc and .domain_free. Therefore, domain-specific resources shouldn't be tied to the device life, but instead to its domain. Signed-off-by: Ezequiel Garcia Reviewed-by: Robin Murphy Acked-by: Heiko Stuebner Signed-off-by: Joerg Roedel Signed-off-by: Sasha Levin --- drivers/iommu/rockchip-iommu.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/iommu/rockchip-iommu.c b/drivers/iommu/rockchip-iommu.c index ad3e2b97469e..140b287e886c 100644 --- a/drivers/iommu/rockchip-iommu.c +++ b/drivers/iommu/rockchip-iommu.c @@ -977,13 +977,13 @@ static struct iommu_domain *rk_iommu_domain_alloc(unsigned type) if (!dma_dev) return NULL; - rk_domain = devm_kzalloc(dma_dev, sizeof(*rk_domain), GFP_KERNEL); + rk_domain = kzalloc(sizeof(*rk_domain), GFP_KERNEL); if (!rk_domain) return NULL; if (type == IOMMU_DOMAIN_DMA && iommu_get_dma_cookie(&rk_domain->domain)) - return NULL; + goto err_free_domain; /* * rk32xx iommus use a 2 level pagetable. @@ -1018,6 +1018,8 @@ err_free_dt: err_put_cookie: if (type == IOMMU_DOMAIN_DMA) iommu_put_dma_cookie(&rk_domain->domain); +err_free_domain: + kfree(rk_domain); return NULL; } @@ -1046,6 +1048,7 @@ static void rk_iommu_domain_free(struct iommu_domain *domain) if (domain->type == IOMMU_DOMAIN_DMA) iommu_put_dma_cookie(&rk_domain->domain); + kfree(rk_domain); } static int rk_iommu_add_device(struct device *dev) -- 2.20.1