Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp3993974pxu; Wed, 9 Dec 2020 06:00:04 -0800 (PST) X-Google-Smtp-Source: ABdhPJwPgyQ2p0MK+3I5tIXQQk4e+18yeTeDoFknjYwNuhbeUEnpi35ykevluth+HWCpnSpHApmP X-Received: by 2002:a05:6402:2066:: with SMTP id bd6mr2112934edb.211.1607522404318; Wed, 09 Dec 2020 06:00:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1607522404; cv=none; d=google.com; s=arc-20160816; b=uxlWmLx1jTvh9XZrRMBeTwLQ/DpASqkUcAi4xKp3h9kTWHGa0YyGEc7M5ebUDeS3jV d+BJIZALhvnkJO6ZdKHJwmrBaZgKykI0opV9FFbOBFnsEqWqGgLzyoWW668U+xSNr/u5 2zcuwTd++Qlmqcv9a6pKfZNWUI7wHLfO4CW7585/LSxMK1HyoW2ZYSfl78mi3pbSR9ZG HUIva0l2oAG18LJteqdE1hEvbedLd9Bbunr/a90c/rZjVp5kyiQzlZjpVss6UlUpxn+u QOIB15zuwH/epI16n0i3J0OLTrcPrtph3sBy+LLpL9ShJcIbGMm5hCTPOrO6/aCkKum8 Z2vg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from; bh=nvz6MWBBIhjkefVUmfcc4rnVD1j5XFZfMeaJYrH5MG4=; b=egq08nfvTVxcMnAnts+C35n8GMoBiG4ojV8P5m0bL9vXJ87XeMY1+zElBM2ZNUNJHU mdmwgg6fQUoJsTQMiSCBD3ieeeiVpaQYJrJJDMiQyHvsVzcscAHjV4n/Xb5BhgLpFKK+ KPqXlQiMAEBxHNInNtxi+76DNTBOdTQIa8CIGCSzhF608VRf2eg4uTjf+WujH2GAnQMD deLLUhxpmkxJ8j3sReWYlXN8xCylAOwHsdYS5yE71wtaMRD9c+vQmltsrizCdHfwLULt Dv0QCQZMwCYjoKouAAX8G1mFMBxfb0vrrpXPoYY3Xsl6Qql01zoooXII+qrinylJKRL2 9znQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=mediatek.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id r9si816267ejr.645.2020.12.09.05.59.41; Wed, 09 Dec 2020 06:00:04 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=mediatek.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728641AbgLIIEb (ORCPT + 99 others); Wed, 9 Dec 2020 03:04:31 -0500 Received: from mailgw01.mediatek.com ([210.61.82.183]:50360 "EHLO mailgw01.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1727720AbgLIIEZ (ORCPT ); Wed, 9 Dec 2020 03:04:25 -0500 X-UUID: 711a3382d9ae4e35adb8b2637ae0397b-20201209 X-UUID: 711a3382d9ae4e35adb8b2637ae0397b-20201209 Received: from mtkexhb01.mediatek.inc [(172.21.101.102)] by mailgw01.mediatek.com (envelope-from ) (Cellopoint E-mail Firewall v4.1.14 Build 0819 with TLSv1.2 ECDHE-RSA-AES256-SHA384 256/256) with ESMTP id 1396262683; Wed, 09 Dec 2020 16:03:43 +0800 Received: from MTKCAS06.mediatek.inc (172.21.101.30) by mtkmbs07n1.mediatek.inc (172.21.101.16) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Wed, 9 Dec 2020 16:03:38 +0800 Received: from localhost.localdomain (10.17.3.153) by MTKCAS06.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Wed, 9 Dec 2020 16:03:41 +0800 From: Yong Wu To: Joerg Roedel , Matthias Brugger , Rob Herring , Will Deacon , Robin Murphy CC: Krzysztof Kozlowski , Evan Green , Tomasz Figa , , , , , , , , , Nicolas Boichat , , Subject: [PATCH v5 15/27] iommu/mediatek: Add fail handle for sysfs_add and device_register Date: Wed, 9 Dec 2020 16:00:50 +0800 Message-ID: <20201209080102.26626-16-yong.wu@mediatek.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20201209080102.26626-1-yong.wu@mediatek.com> References: <20201209080102.26626-1-yong.wu@mediatek.com> MIME-Version: 1.0 Content-Type: text/plain X-MTK: N Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add fail handle for iommu_device_sysfs_add and iommu_device_register. Fixes: b16c0170b53c ("iommu/mediatek: Make use of iommu_device_register interface") Signed-off-by: Yong Wu --- drivers/iommu/mtk_iommu.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/drivers/iommu/mtk_iommu.c b/drivers/iommu/mtk_iommu.c index 39478cfbe0f1..09c8c58feb78 100644 --- a/drivers/iommu/mtk_iommu.c +++ b/drivers/iommu/mtk_iommu.c @@ -746,7 +746,7 @@ static int mtk_iommu_probe(struct platform_device *pdev) ret = iommu_device_register(&data->iommu); if (ret) - return ret; + goto out_sysfs_remove; spin_lock_init(&data->tlb_lock); list_add_tail(&data->list, &m4ulist); @@ -754,7 +754,16 @@ static int mtk_iommu_probe(struct platform_device *pdev) if (!iommu_present(&platform_bus_type)) bus_set_iommu(&platform_bus_type, &mtk_iommu_ops); - return component_master_add_with_match(dev, &mtk_iommu_com_ops, match); + ret = component_master_add_with_match(dev, &mtk_iommu_com_ops, match); + if (ret) + goto out_dev_unreg; + return ret; + +out_dev_unreg: + iommu_device_unregister(&data->iommu); +out_sysfs_remove: + iommu_device_sysfs_remove(&data->iommu); + return ret; } static int mtk_iommu_remove(struct platform_device *pdev) -- 2.18.0