Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp17931596ybl; Thu, 2 Jan 2020 15:03:43 -0800 (PST) X-Google-Smtp-Source: APXvYqwcSzSmb1mTj9aeW7p1x9aCCk7xoAolmzmzWwoCpu61df5xXWmeTObaH+FZ5Hm02XysD8MV X-Received: by 2002:a05:6830:1294:: with SMTP id z20mr91866941otp.60.1578006223673; Thu, 02 Jan 2020 15:03:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1578006223; cv=none; d=google.com; s=arc-20160816; b=XS+OrWI3pal8c5QqhUFOUqOogzzm2zY38uUSLWLoBfjNATVoskkHm4GIajgtBgTWFt QpwxTkUoflfQmmWGo82IhIVIbWoOrfvpsoDRwCSyiSywIa/uhhMsQQ6IBk0FwkFxgnp1 C0wSWDrTorG8dvih8/dQVhHSPRaf+JiolycMpSHXvdWv4sOM3QPuSxgunupyCjZw7oG0 oKIppQB/RCQamgSy8X17rk9TVoRh8wyvbzv6GpDgHctfP1akaQkGiwwNh6GcHIx/Ft8v yZmDJJAQ3lkIsT03bevAEyVkgz+mNMHZ7d0NsWcFK8F+Bq9IrGpimjrlIP5FUtE/DQ5D JbDA== 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=bLny+1oOdJ9UCWWafTksNT7hE01xMwSHjzyiBspegCc=; b=g5ivp7+HEuaCPsfnXq1hcItcX1M7UnOa69hgMQDNCUsmE0j+1zNsR1qjjFDTtqRMBP oBdkTYuO8mIM6bW4dynkmXao0et5iwye9gkuFe/npqSCzp/KA9UQ/462bN2ajz7sJ0NT lhwOsJgSkHXSt7C/gsJUAlQKqm3vkEUuRkT8z4nO5GK9CC+HWqDLvnfJ1K2i80vZsjqB rLaZ3HJFWFUzx9HSm+v4hK6a+1UwfiWXgd+cMts4YRZx9D4e42XIS7UmDSJTBbLs+5Bl DoPXEUC9CXYWURQZQSjhdfutngXL2U8Eot12ZyCA4WE+Uj/0DXjUg/EDWF6FAS+S0FLG LY0Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=fYxp7PwO; 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 z12si28081157otm.189.2020.01.02.15.03.31; Thu, 02 Jan 2020 15:03: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; dkim=pass header.i=@kernel.org header.s=default header.b=fYxp7PwO; 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 S1727074AbgABWLc (ORCPT + 99 others); Thu, 2 Jan 2020 17:11:32 -0500 Received: from mail.kernel.org ([198.145.29.99]:49582 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726702AbgABWL2 (ORCPT ); Thu, 2 Jan 2020 17:11:28 -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 B279721D7D; Thu, 2 Jan 2020 22:11:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1578003088; bh=0hcivgfnIPv5RFLLByzSdVuZjO4Jod2h9/haKpKzhhc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fYxp7PwOH58ffwkpX0nP9OvjU0yE5ZY0lD8NG0pm6DktjEo96AtVQ71lRZljrMkKi s+r3/so4nrtOT8VtgVs19C28yealB/DIhOcxKHRg8A3nRqV8+cjcGxLXW2pzGSETf5 /Jo1dl9SJFIgDgl7OYxTbHZpP5Nlk/3uWBSl4a/E= 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 5.4 015/191] iommu: rockchip: Free domain on .domain_free Date: Thu, 2 Jan 2020 23:04:57 +0100 Message-Id: <20200102215831.389395073@linuxfoundation.org> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200102215829.911231638@linuxfoundation.org> References: <20200102215829.911231638@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 4dcbf68dfda4..0df091934361 100644 --- a/drivers/iommu/rockchip-iommu.c +++ b/drivers/iommu/rockchip-iommu.c @@ -980,13 +980,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. @@ -1021,6 +1021,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; } @@ -1049,6 +1051,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