From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3DF05C47082 for ; Tue, 8 Jun 2021 09:31:40 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 04ADE61108 for ; Tue, 8 Jun 2021 09:31:39 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 04ADE61108 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=Ie5eDC/J4TSixxeJL0KdEr8r3jIoXgz5SJ+psOFdiDc=; b=L523rlRMj/kcB+ sxG1lgJ5dW9qNQMpmgQv6+XtQhveVDkNVLdBn2arn8ew/AN57y00/lohD/1pDsYAWOUnBZDPPHXBM 1Fj3DJGnjbyGdh6l5VNh7r+mjw8tQrdQsnfRP9NpGEqxyOqmXQnt/daQd9azC7OsloN+bo57xBuFh wYMdveNTk6BfUeMsHpGdRIVmVZGP92zqPFhr3zM0NFdjk8As+b1H48YS7IsQ9XchwRBBmqNCvZui/ vOjpN/g0LIHuUMrCnnZFf5BcB2nXtcJCRk4ImlSkuK9P6+4nFPhbKnh8LoHGr8mjFGw8nag0/funm E/ZWJiWnmCGhvW50/lWw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1lqY3l-007Qow-EV; Tue, 08 Jun 2021 09:30:09 +0000 Received: from mail.kernel.org ([198.145.29.99]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1lqY3f-007Qnw-Bh for linux-arm-kernel@lists.infradead.org; Tue, 08 Jun 2021 09:30:04 +0000 Received: by mail.kernel.org (Postfix) with ESMTPSA id 9446D61278; Tue, 8 Jun 2021 09:30:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1623144603; bh=MhokyPxqdEzZc6RC+avxqxp0BKKYNFp7L+EMYDuA2a8=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=pnPVfHt9Tyl2Tb3E3ugOua/bzj+uG374ur35ZQ0HwbgRP+yx9Dz0uCaFhay5a9VoQ RL/1sm0Jnd1wp0hZU6D+iIdsFeSFPGxDzqxR3qFY6N0EBbOkl3hBrqLgPu+NFAu3ys Lk8/abZR2hXWtYG4qRJLS4BteETl12Lp1mO73vyuz3qbIY+uVRNp8dBUWZUbb43209 TWH+1WZdJZukihn6qloH4L5LdtsSEsgoIZvUi4Hlbf+xZdo+AFib1dmj1uVLzWMgZR 6zDqLCFCBOJp4vfxMiFFWZgjMk5HsXi+5n9Dzp0ZcDFHHQppk5Kep732yOLJXTcZz+ +tBL3vyJdzEIw== Date: Tue, 8 Jun 2021 10:29:58 +0100 From: Will Deacon To: Amey Narkhede Cc: Rob Clark , Robin Murphy , Joerg Roedel , iommu@lists.linux-foundation.org, linux-arm-msm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] iommu/qcom: Cleanup resources in case of probe error path Message-ID: <20210608092958.GA8935@willie-the-truck> References: <20210421221030.70647-1-ameynarkhede03@gmail.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20210421221030.70647-1-ameynarkhede03@gmail.com> User-Agent: Mutt/1.10.1 (2018-07-13) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210608_023003_464227_B7038098 X-CRM114-Status: GOOD ( 17.15 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Thu, Apr 22, 2021 at 03:40:30AM +0530, Amey Narkhede wrote: > If device registration fails, remove sysfs attribute > and if setting bus callbacks fails, unregister the device > and cleanup the sysfs attribute. > > Signed-off-by: Amey Narkhede > --- > drivers/iommu/arm/arm-smmu/qcom_iommu.c | 14 ++++++++++++-- > 1 file changed, 12 insertions(+), 2 deletions(-) > > diff --git a/drivers/iommu/arm/arm-smmu/qcom_iommu.c b/drivers/iommu/arm/arm-smmu/qcom_iommu.c > index 4294abe389b2..5fa128a1f7f0 100644 > --- a/drivers/iommu/arm/arm-smmu/qcom_iommu.c > +++ b/drivers/iommu/arm/arm-smmu/qcom_iommu.c > @@ -850,10 +850,12 @@ static int qcom_iommu_device_probe(struct platform_device *pdev) > ret = iommu_device_register(&qcom_iommu->iommu, &qcom_iommu_ops, dev); > if (ret) { > dev_err(dev, "Failed to register iommu\n"); > - return ret; > + goto err_sysfs_remove; > } > > - bus_set_iommu(&platform_bus_type, &qcom_iommu_ops); > + ret = bus_set_iommu(&platform_bus_type, &qcom_iommu_ops); > + if (ret) > + goto err_unregister_device; > > if (qcom_iommu->local_base) { > pm_runtime_get_sync(dev); > @@ -862,6 +864,14 @@ static int qcom_iommu_device_probe(struct platform_device *pdev) > } > > return 0; > + > +err_unregister_device: > + iommu_device_unregister(&qcom_iommu->iommu); > + > +err_sysfs_remove: > + iommu_device_sysfs_remove(&qcom_iommu->iommu); > + > + return ret; It looks like we're also missing this logic in arm-smmu/arm-smmu.c and arm-smmu-v3/arm-smmu-v3.c. Would you be able to fix those up too, please? Will _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel