From patchwork Fri Mar 2 10:10:46 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vivek Gautam X-Patchwork-Id: 10254105 X-Patchwork-Delegate: agross@codeaurora.org Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 20C286037F for ; Fri, 2 Mar 2018 10:14:24 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0725728963 for ; Fri, 2 Mar 2018 10:14:24 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id EE28328956; Fri, 2 Mar 2018 10:14:23 +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=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 855A32895F for ; Fri, 2 Mar 2018 10:14:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1426207AbeCBKLR (ORCPT ); Fri, 2 Mar 2018 05:11:17 -0500 Received: from smtp.codeaurora.org ([198.145.29.96]:46520 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1426176AbeCBKLJ (ORCPT ); Fri, 2 Mar 2018 05:11:09 -0500 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id 82E9A607DC; Fri, 2 Mar 2018 10:11:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1519985468; bh=t+iGkNYAxeFxmQzCf5sZRL8dPoLw2AjVc8SkvNj5mRM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YMfcqoqd4+dMuo7hf5rKHd9VEs28bvDeSVI8N6SLP1LzxJ9DM2RVvVshSSUDhfGhJ aECV/6X/4yIqYYB939kTyV2hlmkaCqJjxlKmM9teLUSwvqI2QfI3JIzLS811gR5+Qj +lfpqYuCagmAC6HeyVOj47pCezavYqo2TLpBxgQA= Received: from blr-ubuntu-41.ap.qualcomm.com (blr-bdr-fw-01_globalnat_allzones-outside.qualcomm.com [103.229.18.19]) (using TLSv1.1 with cipher ECDHE-RSA-AES128-SHA (128/128 bits)) (No client certificate requested) (Authenticated sender: vivek.gautam@smtp.codeaurora.org) by smtp.codeaurora.org (Postfix) with ESMTPSA id 0DB676076C; Fri, 2 Mar 2018 10:11:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1519985467; bh=t+iGkNYAxeFxmQzCf5sZRL8dPoLw2AjVc8SkvNj5mRM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=X47Vq6PEGuoXattDAFqHwlUD875W4QzZK+yEExTsejCVEwibTuOoEjl6bwvoFKdgW Zh+GWC1nkM0MxFR1DTilm6sq82oPHb51WC8OZnwdV27s68WyJaON2n9T3cXWE+oP7g Nks+LAFTE4XGdcjxto15pPsHyO5WYdRs9N+XecP0= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 0DB676076C Authentication-Results: pdx-caf-mail.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: pdx-caf-mail.web.codeaurora.org; spf=none smtp.mailfrom=vivek.gautam@codeaurora.org From: Vivek Gautam To: joro@8bytes.org, robh+dt@kernel.org, mark.rutland@arm.com, rjw@rjwysocki.net, robin.murphy@arm.com, will.deacon@arm.com, robdclark@gmail.com, iommu@lists.linux-foundation.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Cc: tfiga@chromium.org, jcrouse@codeaurora.org, sboyd@codeaurora.org, sricharan@codeaurora.org, m.szyprowski@samsung.com, architt@codeaurora.org, linux-arm-msm@vger.kernel.org, vivek.gautam@codeaurora.org Subject: [PATCH v8 1/5] iommu/arm-smmu: Destroy domain context in failure path Date: Fri, 2 Mar 2018 15:40:46 +0530 Message-Id: <20180302101050.6191-2-vivek.gautam@codeaurora.org> X-Mailer: git-send-email 2.16.1.72.g5be1f00a9a70 In-Reply-To: <20180302101050.6191-1-vivek.gautam@codeaurora.org> References: <20180302101050.6191-1-vivek.gautam@codeaurora.org> Sender: linux-arm-msm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP If we fail after initializing domain_context, we should destroy the context to free up resources. Signed-off-by: Vivek Gautam --- * New patch added in this series. drivers/iommu/arm-smmu.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/drivers/iommu/arm-smmu.c b/drivers/iommu/arm-smmu.c index 69e7c60792a8..ffc152c36002 100644 --- a/drivers/iommu/arm-smmu.c +++ b/drivers/iommu/arm-smmu.c @@ -1223,11 +1223,16 @@ static int arm_smmu_attach_dev(struct iommu_domain *domain, struct device *dev) dev_err(dev, "cannot attach to SMMU %s whilst already attached to domain on SMMU %s\n", dev_name(smmu_domain->smmu->dev), dev_name(smmu->dev)); - return -EINVAL; + ret = -EINVAL; + goto destroy_domain; } /* Looks ok, so add the device to the domain */ return arm_smmu_domain_add_master(smmu_domain, fwspec); + +destroy_domain: + arm_smmu_destroy_domain_context(domain); + return ret; } static int arm_smmu_map(struct iommu_domain *domain, unsigned long iova,