Received: by 10.223.185.116 with SMTP id b49csp8468686wrg; Fri, 2 Mar 2018 02:16:32 -0800 (PST) X-Google-Smtp-Source: AG47ELs9YfQgXEKcr+D12aZz2J1LXAhtDzHBFIdynV8kcSBFv0aXwGcrTmPNTuXx9f3Vbt8rpSew X-Received: by 2002:a17:902:864b:: with SMTP id y11-v6mr4811581plt.380.1519985792255; Fri, 02 Mar 2018 02:16:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519985792; cv=none; d=google.com; s=arc-20160816; b=YvI8J8qn9ZZ82gforql1/8qMLN1oku30voFb1MhOEkAfJ1pM/jdhkbPZ2VUDdRJ3MC uSsbSEiuRSAI4lf1sgVoEstGDr/n1+IOvsk+TDIJvOaOjR7Kfmljgyrwya2QLO/zpREX 2TQHEA1z8bUyPkIzYqLwlhFSenHggxO0Re0RQN1LfiDyNQiYxrILvswJU0VxfVqfW6mB W+n8QMUP7eUwwOxpJC/zziWjctkzPZnD+aDn7h8ee7nJnfNvu2vFEKnIcoe/VUsZDSXm q58TYYFVYxzwheAPo5GWS+hpz8EysOVk4ujVupQ7qKoyVwyXQtCxkinqc373HeV4B3ta 3e8w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dmarc-filter:dkim-signature:dkim-signature :arc-authentication-results; bh=TZQdDMIoaadyrhHnaytOn/wix1fM+XW23rbC24wojlg=; b=tOZFbRUg9zd8AvAUj8/W/Ejl3nPeNOYz9ENyMYGJK1iCzmFZhaiLlhmr1fti5+TWF9 CkcZVySFy88/LZ60ojXQACrmXhgUHjzOwm9SH+7UCkaT9GMrwoRoN51mnwKqIfELq+FC RRDp5Ftt+6dsitY1eiwVO6RKo6yXhlEEBuNR0WtuX1sCTIr1rigkmvdDPBtj2dSJyq48 HTMXQ02AIVFGpyxhw2EAFTxMduJbJ29KDMBYNakmlhpNjf16W6+50OVPdDHTwRfPXB7i GKmD54co7Wyr8PZVEBIHDGaxjilguwlVQUXeYEYvWnXFycxeR1uJwDfrARWrcixe5sAl T92w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@codeaurora.org header.s=default header.b=YMfcqoqd; dkim=pass header.i=@codeaurora.org header.s=default header.b=X47Vq6PE; 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 m16si3779898pgn.290.2018.03.02.02.16.17; Fri, 02 Mar 2018 02:16:32 -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=@codeaurora.org header.s=default header.b=YMfcqoqd; dkim=pass header.i=@codeaurora.org header.s=default header.b=X47Vq6PE; 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 S1426219AbeCBKLS (ORCPT + 99 others); Fri, 2 Mar 2018 05:11:18 -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= X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on pdx-caf-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.8 required=2.0 tests=ALL_TRUSTED,BAYES_00, DKIM_SIGNED,T_DKIM_INVALID autolearn=no autolearn_force=no version=3.4.0 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-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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, -- QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by The Linux Foundation