Received: by 2002:a05:6a10:2785:0:0:0:0 with SMTP id ia5csp2188453pxb; Mon, 11 Jan 2021 03:25:18 -0800 (PST) X-Google-Smtp-Source: ABdhPJwTkkAsQqpqfATvVvf+kUEbZhxjeY7LtefvBuEuBJbYEbW1ZZxeKHh2y+vLxArepn4+bs8I X-Received: by 2002:a50:a684:: with SMTP id e4mr13500639edc.148.1610364318409; Mon, 11 Jan 2021 03:25:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1610364318; cv=none; d=google.com; s=arc-20160816; b=xrCd6ZMFxyLJZVp79Ir72WsYmzoO9/dP5wV8PcjZ4Y24ReDDJgGFORtWBcbDQeWQVL Jn2sKPcKe+7N98OchY0oTvpW4mLeOZ7cGyT+q8Kxmojy6XPhuoToHQ+8XU3qTCsl6Iwz +axZJQRK5EmTTRkgBDrK5IouPugQdKFJdYaxWMpmICILw+jM6wA/oUpyJnIOZeo8ZmdF M4N3UvvggfQN7vmbVvzH6YMkd1GMFWmXujaUiiUdM/gB/hbgVvSbqtPDluuN3sj/HyEP 4ixKq5zil6C1GwU1ktG/EP5M41Wi41YAHfpOXn8u9/RgF00ftLOBbGazcWMb8bQkVn4M g3fA== 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=6PS/kIcIuq9fFE60pCMvZwtgHsi3tAMIl5NUDfNcX1c=; b=T1E4uG54TOFcVFlbItA3kzxDQ53116uk99X/hcAWxDtgEBX1PDxo4QWtmv+CR3BGrc XwaQe5H7aS/1ZcV29xCtqJtJLt71aceX8NJ7EAe7wvPOG0eukbqbt8jbc+DGscucxZ+n aKx3eojk7a13KJ4tqf55OALHFKrTzvMyxBg+zs/OS6uoa4LvEX/XkwA7UUDund/k8lNS s0Rq8xZni5kEDUjRu4PTTn0AuP79+cXRi4xTxJzSpFbqIxO3SYyA3o1SAylHw42vt2D0 QC+68B4FC44jzQ6gvBwsrnIcQHaqksSPQjsGAzq1CgpIS6WyrAVSm0xQuIsT0TQvl4Xn bbqQ== 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 k26si6787436edx.279.2021.01.11.03.24.54; Mon, 11 Jan 2021 03:25:18 -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 S1729865AbhAKLWu (ORCPT + 99 others); Mon, 11 Jan 2021 06:22:50 -0500 Received: from mailgw01.mediatek.com ([210.61.82.183]:60479 "EHLO mailgw01.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1728305AbhAKLWs (ORCPT ); Mon, 11 Jan 2021 06:22:48 -0500 X-UUID: 2aaf4159c1d540bfb639c70b9762cfcb-20210111 X-UUID: 2aaf4159c1d540bfb639c70b9762cfcb-20210111 Received: from mtkcas10.mediatek.inc [(172.21.101.39)] 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 2101849858; Mon, 11 Jan 2021 19:22:10 +0800 Received: from mtkcas11.mediatek.inc (172.21.101.40) by mtkmbs07n1.mediatek.inc (172.21.101.16) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Mon, 11 Jan 2021 19:22:09 +0800 Received: from localhost.localdomain (10.17.3.153) by mtkcas11.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Mon, 11 Jan 2021 19:22:08 +0800 From: Yong Wu To: Joerg Roedel , Rob Herring , Matthias Brugger , Will Deacon , Robin Murphy CC: Krzysztof Kozlowski , Evan Green , Tomasz Figa , , , , , , , , , Nicolas Boichat , , Subject: [PATCH v6 17/33] iommu/mediatek: Add error handle for mtk_iommu_probe Date: Mon, 11 Jan 2021 19:18:58 +0800 Message-ID: <20210111111914.22211-18-yong.wu@mediatek.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20210111111914.22211-1-yong.wu@mediatek.com> References: <20210111111914.22211-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 In the original code, we lack the error handle. This patch adds them. Signed-off-by: Yong Wu --- drivers/iommu/mtk_iommu.c | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/drivers/iommu/mtk_iommu.c b/drivers/iommu/mtk_iommu.c index 87c4626c9072..189165e7a2ab 100644 --- a/drivers/iommu/mtk_iommu.c +++ b/drivers/iommu/mtk_iommu.c @@ -739,15 +739,30 @@ 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); - if (!iommu_present(&platform_bus_type)) - bus_set_iommu(&platform_bus_type, &mtk_iommu_ops); + if (!iommu_present(&platform_bus_type)) { + ret = bus_set_iommu(&platform_bus_type, &mtk_iommu_ops); + if (ret) + goto out_list_del; + } - 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_bus_set_null; + return ret; + +out_bus_set_null: + bus_set_iommu(&platform_bus_type, NULL); +out_list_del: + list_del(&data->list); + 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