Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp1141219imm; Wed, 1 Aug 2018 10:52:24 -0700 (PDT) X-Google-Smtp-Source: AAOMgpd/7D/Wn5mp0/whqdBJSH77oTMKFpIhVIBNn0x7Pe6DSwDNgD8x8GXJukUMh1A0rIsAtGX5 X-Received: by 2002:a65:49c7:: with SMTP id t7-v6mr25846136pgs.23.1533145944727; Wed, 01 Aug 2018 10:52:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1533145944; cv=none; d=google.com; s=arc-20160816; b=b6yYCd1OrXFr9jhiNNDWEzo21y9n6w/Q4GkLqBiFdO8B7n9Y9gzZcGtcs8NpnRl3ca PR+DT3GExBZSJK5ziPbFo+LySEg4OovSYFaPVCCCKJwmqhfXOUCXTDmCKoTpu5IQ9COi uUHM5V9oW7A5znA2BJrnGSfVgko3P2wh4BMIMy7H35h/zyiBrHvhwvk6+wjqP6KRw+Iy ZpmipxG8u7qg846Sq65UYjTmwf9fptpd4IWwhXEJK5DDxuhS/JXJexPlE+pkMpQkGUXg XaiZjVAeRmMBURiZzxnLI5+oN8ueTJn+jVsDgxhk6iRzAdHVajY5fUlZGJtYopY/YrSz AWbA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=rjnqOi7wAWPwZiYMUGCHUmxMXeF+jMTPQRjcSVajBwQ=; b=BnUQVwNZejEJOxbNYoLeGCisXow6YQpkcmT4lnh4hxNyx8zR4gzXrHH9yL3OIY+0QU 2lGlSlFJg18cqvzLtTjhkdVNC9seWLXByBfvufdVwoBD1ARmRW3AUEl+9TmKDgfRMYa1 02k5gZX33A2FJb5ozRTG6ubH+JeZ/VtjoyiA5HeQOlahW9EeeZhNANqniT8OvPhvmGUr 21/0+mnVSHn57uxZuWi2gkwZD1wk9NZYow7Lny3WIj1HHvdB6O1lAfrJ+aOXALTL3uFB 1qhMRtrf6CFgT5PB4BrvScL5GIdvReaFza4mKZk8wWL8GC8GmU/A25jCM/nsjICwZ+4T wJbA== ARC-Authentication-Results: i=1; mx.google.com; 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 s23-v6si16867305pgs.499.2018.08.01.10.52.10; Wed, 01 Aug 2018 10:52:24 -0700 (PDT) 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; 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 S2406136AbeHATIn (ORCPT + 99 others); Wed, 1 Aug 2018 15:08:43 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:50080 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2406040AbeHATIl (ORCPT ); Wed, 1 Aug 2018 15:08:41 -0400 Received: from localhost (D57E6652.static.ziggozakelijk.nl [213.126.102.82]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id AE5B5CC9; Wed, 1 Aug 2018 17:21:52 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Pavel Machek , Suman Anna , Laurent Pinchart , Sakari Ailus , Mauro Carvalho Chehab , Sasha Levin Subject: [PATCH 4.14 202/246] media: omap3isp: fix unbalanced dma_iommu_mapping Date: Wed, 1 Aug 2018 18:51:52 +0200 Message-Id: <20180801165021.393705242@linuxfoundation.org> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180801165011.700991984@linuxfoundation.org> References: <20180801165011.700991984@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.14-stable review patch. If anyone has any objections, please let me know. ------------------ From: Suman Anna [ Upstream commit b7e1e6859fbf60519fd82d7120cee106a6019512 ] The OMAP3 ISP driver manages its MMU mappings through the IOMMU-aware ARM DMA backend. The current code creates a dma_iommu_mapping and attaches this to the ISP device, but never detaches the mapping in either the probe failure paths or the driver remove path resulting in an unbalanced mapping refcount and a memory leak. Fix this properly. Reported-by: Pavel Machek Signed-off-by: Suman Anna Tested-by: Pavel Machek Reviewed-by: Laurent Pinchart Signed-off-by: Sakari Ailus Signed-off-by: Mauro Carvalho Chehab Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- drivers/media/platform/omap3isp/isp.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) --- a/drivers/media/platform/omap3isp/isp.c +++ b/drivers/media/platform/omap3isp/isp.c @@ -1945,6 +1945,7 @@ error_csi2: static void isp_detach_iommu(struct isp_device *isp) { + arm_iommu_detach_device(isp->dev); arm_iommu_release_mapping(isp->mapping); isp->mapping = NULL; } @@ -1961,8 +1962,7 @@ static int isp_attach_iommu(struct isp_d mapping = arm_iommu_create_mapping(&platform_bus_type, SZ_1G, SZ_2G); if (IS_ERR(mapping)) { dev_err(isp->dev, "failed to create ARM IOMMU mapping\n"); - ret = PTR_ERR(mapping); - goto error; + return PTR_ERR(mapping); } isp->mapping = mapping; @@ -1977,7 +1977,8 @@ static int isp_attach_iommu(struct isp_d return 0; error: - isp_detach_iommu(isp); + arm_iommu_release_mapping(isp->mapping); + isp->mapping = NULL; return ret; }