Received: by 2002:a05:6a10:17d3:0:0:0:0 with SMTP id hz19csp1538636pxb; Sun, 11 Apr 2021 23:51:18 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxr0albDIjQu8ZxfJXKBRYAC14tUXnM18SSZQtQZ1lJsO4kzQOf4oJvrggmUe5lQtb50her X-Received: by 2002:aa7:d78a:: with SMTP id s10mr27425466edq.226.1618210277985; Sun, 11 Apr 2021 23:51:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1618210277; cv=none; d=google.com; s=arc-20160816; b=hGXZUDjx+zPWy1rUUXUof+P36dO7Dnoiss+mA+8GSaJcMnzybnt0rDb4Mrkbc63vRD y7i8AoGR31Q9QhiWOGlfnjls1IcKocTTpjym5zrH+Pvfao0MU3WLJlf+IcvUBsJCZpeS 4sKVkAOop/UyhGs5bddGbWwZZ5f5ZQIYxJGuhBYWnzDRjMecGuQnP6MQCmz/k1pAlYaG VbmTtSRJxedJ+Eqinzf0gjF8xEx2h4/FxKA7eReDDhmFt+sK2mM4O3XCZkgfnmvVV1nC unBStCLqXRfUzccJiZ+ldrOhQImfSTKi8w9ToXdbdgixRnmmkDV4kfdg10rk1CCpBpcA XD/w== 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=ZV6o0pgFnNNrhSvk8pSMUNrYJFuFU4Qtk2QV9sPGLTA=; b=HHsgM9Re5HSYm+jEkfcHRAa8TAcToEgikdy6bKrV4wV6FSgphbF6rTbPbAtXUg355x P50DKG1EFGk55oJJipcFG2Cyf1Wmmm9T6zoorDhzrIG7aWl09jXuyj9vu3oD0Euu3ZIi NPDacyeAG8H3jFJHVA4ZvIToGpYeZvBBl5XUIR68j3wQHaaJuLxLEtf9ZSfIKiAiOMI6 tMFjw9ZbHPYH34tvbYrYBCGBY0OCvOTOc/1RiwOv91UKo0uoeIRVQDjUbt5sxrG9LWq6 zAKR3Pe+fH65c2xuPIVXme269n/kEq/aokcuKCka1Ih45fTNGayTXSZQAyvQuhKFGyst qsHQ== 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 dt26si7132125ejb.142.2021.04.11.23.50.55; Sun, 11 Apr 2021 23:51:17 -0700 (PDT) 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 S236593AbhDLGtW (ORCPT + 99 others); Mon, 12 Apr 2021 02:49:22 -0400 Received: from mailgw02.mediatek.com ([210.61.82.184]:44405 "EHLO mailgw02.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S229461AbhDLGtU (ORCPT ); Mon, 12 Apr 2021 02:49:20 -0400 X-UUID: 98d1fea8274b4564a83a3655d427fd58-20210412 X-UUID: 98d1fea8274b4564a83a3655d427fd58-20210412 Received: from mtkmrs01.mediatek.inc [(172.21.131.159)] by mailgw02.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 954585324; Mon, 12 Apr 2021 14:49:01 +0800 Received: from mtkcas07.mediatek.inc (172.21.101.84) by mtkmbs07n2.mediatek.inc (172.21.101.141) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Mon, 12 Apr 2021 14:49:00 +0800 Received: from localhost.localdomain (10.17.3.153) by mtkcas07.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Mon, 12 Apr 2021 14:48:59 +0800 From: Yong Wu To: Joerg Roedel , Will Deacon CC: Matthias Brugger , Robin Murphy , Tomasz Figa , , , , , , Krzysztof Kozlowski , , , , , Valdis Kletnieks Subject: [PATCH 2/2] iommu/mediatek-v1: Add error handle for mtk_iommu_probe Date: Mon, 12 Apr 2021 14:48:43 +0800 Message-ID: <20210412064843.11614-2-yong.wu@mediatek.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20210412064843.11614-1-yong.wu@mediatek.com> References: <20210412064843.11614-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_v1.c | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/drivers/iommu/mtk_iommu_v1.c b/drivers/iommu/mtk_iommu_v1.c index bed0bb9d63fd..8ba9a2ec5509 100644 --- a/drivers/iommu/mtk_iommu_v1.c +++ b/drivers/iommu/mtk_iommu_v1.c @@ -620,12 +620,26 @@ static int mtk_iommu_probe(struct platform_device *pdev) ret = iommu_device_register(&data->iommu); if (ret) - return ret; + goto out_sysfs_remove; - 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_dev_unreg; + } - 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_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