From patchwork Tue Apr 5 13:50:32 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Keeping X-Patchwork-Id: 8752071 Return-Path: X-Original-To: patchwork-dri-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id C576F9FC89 for ; Tue, 5 Apr 2016 13:51:01 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id E9796203B7 for ; Tue, 5 Apr 2016 13:51:00 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 90FBA203A5 for ; Tue, 5 Apr 2016 13:50:59 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 0A2706E7B7; Tue, 5 Apr 2016 13:50:59 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from metanate.com (dougal.metanate.com [90.155.101.14]) by gabe.freedesktop.org (Postfix) with ESMTPS id 205816E7B6 for ; Tue, 5 Apr 2016 13:50:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=simple/simple; d=metanate.com; s=stronger; h=References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From; bh=47NylZYnN1dRossKwTZS2UoRot0hC+fYxBnRCqLC7W4=; b=pDXqAT8/3GdhlgDJFD6AL9N4OkTljEjS1U9phGG9nTrCQFdV8j0kj4FlA/I3crNKh5wRz1zuThZKbOYJiBu+ivFKV3IVckaAFfS115t2nfZZRZo/ny9/pmEIQ79XIl/GmA1IquMF7uWXlznykl9m5qbkZGtKVpW9TNfC6JkCrHYzXebCOiCj3U+Y32vovAeKmT2Xx7jnzc4lzvX+Yx7IG1oZTSQEeSSeIgv0akpVQJGblp8Vcl7z77/knXrOXsaGUyGxdb5mENz+eIP+4Z+Ox9a4EuOoO7LmdAtc3CXnuyHFv3tyXb510wkakd5G81XEwVJTTim4VPCluTfe8JpUWA==; Received: from brian ([192.168.88.1] helo=leela.metanate.com) by shrek.metanate.com with esmtpsa (TLSv1.2:AES128-SHA256:128) (Exim 4.83_RC2) (envelope-from ) id 1anRNY-0004w2-RY; Tue, 05 Apr 2016 14:50:48 +0100 From: John Keeping To: Mark Yao Subject: [PATCH 2/2] drm/rockchip: don't leak iommu mapping Date: Tue, 5 Apr 2016 14:50:32 +0100 Message-Id: <1459864232-25033-2-git-send-email-john@metanate.com> X-Mailer: git-send-email 2.8.0.rc4.238.g874082a In-Reply-To: <1459864232-25033-1-git-send-email-john@metanate.com> References: <1459864232-25033-1-git-send-email-john@metanate.com> Cc: linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-rockchip@lists.infradead.org, linux-arm-kernel@lists.infradead.org X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Spam-Status: No, score=-5.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,RP_MATCHES_RCVD,T_DKIM_INVALID,UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP arm_iommu_attach_device() takes its own reference to the mapping we give it. Since we do not keep a reference to the mapping ourselves, we must release it before returning. Also fix the error path, which fails to release the mapping if it has called arm_iommu_detach_device() since that clears archdata.mapping. Signed-off-by: John Keeping --- drivers/gpu/drm/rockchip/rockchip_drm_drv.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_drv.c b/drivers/gpu/drm/rockchip/rockchip_drm_drv.c index 7695c79..1e2d88b 100644 --- a/drivers/gpu/drm/rockchip/rockchip_drm_drv.c +++ b/drivers/gpu/drm/rockchip/rockchip_drm_drv.c @@ -218,6 +218,7 @@ static int rockchip_drm_load(struct drm_device *drm_dev, unsigned long flags) if (ret) goto err_vblank_cleanup; + arm_iommu_release_mapping(mapping); return 0; err_vblank_cleanup: drm_vblank_cleanup(drm_dev); @@ -228,7 +229,7 @@ err_unbind: err_detach_device: arm_iommu_detach_device(dev); err_release_mapping: - arm_iommu_release_mapping(dev->archdata.mapping); + arm_iommu_release_mapping(mapping); err_config_cleanup: drm_mode_config_cleanup(drm_dev); drm_dev->dev_private = NULL;