Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756163AbcCWWZi (ORCPT ); Wed, 23 Mar 2016 18:25:38 -0400 Received: from mail-pf0-f196.google.com ([209.85.192.196]:35769 "EHLO mail-pf0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755508AbcCWWZb (ORCPT ); Wed, 23 Mar 2016 18:25:31 -0400 From: Wei Yang To: treding@nvidia.com, alex.williamson@redhat.com Cc: joro@8bytes.org, iommu@lists.linux-foundation.org, linux-kernel@vger.kernel.org, Wei Yang Subject: [Patch V2 2/2] iommu: remove sysfs_link to device in iommu_group/devices when failed Date: Wed, 23 Mar 2016 22:25:11 +0000 Message-Id: <1458771911-30785-3-git-send-email-richard.weiyang@gmail.com> X-Mailer: git-send-email 2.5.0 In-Reply-To: <1458771911-30785-1-git-send-email-richard.weiyang@gmail.com> References: <1458771911-30785-1-git-send-email-richard.weiyang@gmail.com> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 742 Lines: 25 The original code forgets to remove the sysfs_link to a device in iommu_group/devices directory, when the creation fails or conflicts on the name. This patch tries to remove the sysfs_link on the failure. Signed-off-by: Wei Yang --- drivers/iommu/iommu.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c index 2696a38..8f480ba 100644 --- a/drivers/iommu/iommu.c +++ b/drivers/iommu/iommu.c @@ -403,6 +403,7 @@ rename: ret = sysfs_create_link_nowarn(group->devices_kobj, &dev->kobj, device->name); if (ret) { + sysfs_remove_link(group->devices_kobj, device->name); kfree(device->name); if (ret == -EEXIST && i >= 0) { /* -- 1.7.9.5