Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751704AbeAPN0b (ORCPT + 1 other); Tue, 16 Jan 2018 08:26:31 -0500 Received: from regular1.263xmail.com ([211.150.99.141]:42271 "EHLO regular1.263xmail.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751118AbeAPN03 (ORCPT ); Tue, 16 Jan 2018 08:26:29 -0500 X-263anti-spam: KSV:0; X-MAIL-GRAY: 0 X-MAIL-DELIVERY: 1 X-KSVirus-check: 0 X-ABS-CHECKED: 4 X-RL-SENDER: jeffy.chen@rock-chips.com X-FST-TO: linux-kernel@vger.kernel.org X-SENDER-IP: 103.29.142.67 X-LOGIN-NAME: jeffy.chen@rock-chips.com X-UNIQUE-TAG: <89b40d6e08db7d3eadb30232f419771e> X-ATTACHMENT-NUM: 0 X-DNS-TYPE: 0 From: Jeffy Chen To: linux-kernel@vger.kernel.org Cc: jcliang@chromium.org, robin.murphy@arm.com, xxm@rock-chips.com, tfiga@chromium.org, Jeffy Chen , Heiko Stuebner , linux-rockchip@lists.infradead.org, iommu@lists.linux-foundation.org, Joerg Roedel , linux-arm-kernel@lists.infradead.org Subject: [PATCH v2 04/13] iommu/rockchip: Fix error handling in probe Date: Tue, 16 Jan 2018 21:25:31 +0800 Message-Id: <20180116132540.18939-5-jeffy.chen@rock-chips.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180116132540.18939-1-jeffy.chen@rock-chips.com> References: <20180116132540.18939-1-jeffy.chen@rock-chips.com> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Return-Path: Add missing iommu_device_sysfs_remove in error path. Also adjust sequence of deinit functions in the remove. Signed-off-by: Jeffy Chen --- Changes in v2: None drivers/iommu/rockchip-iommu.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/drivers/iommu/rockchip-iommu.c b/drivers/iommu/rockchip-iommu.c index 4ffb3a65c9d2..bd8b32dc0db6 100644 --- a/drivers/iommu/rockchip-iommu.c +++ b/drivers/iommu/rockchip-iommu.c @@ -1182,18 +1182,20 @@ static int rk_iommu_probe(struct platform_device *pdev) iommu_device_set_ops(&iommu->iommu, &rk_iommu_ops); err = iommu_device_register(&iommu->iommu); + if (err) { + iommu_device_sysfs_remove(&iommu->iommu); + return err; + } - return err; + return 0; } static int rk_iommu_remove(struct platform_device *pdev) { struct rk_iommu *iommu = platform_get_drvdata(pdev); - if (iommu) { - iommu_device_sysfs_remove(&iommu->iommu); - iommu_device_unregister(&iommu->iommu); - } + iommu_device_unregister(&iommu->iommu); + iommu_device_sysfs_remove(&iommu->iommu); return 0; } -- 2.11.0