[Patch V2 2/2] iommu: remove sysfs_link to device in iommu_group/devices when failed

From: Wei Yang
Date: Wed Mar 23 2016 - 18:25:42 EST


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 <richard.weiyang@xxxxxxxxx>
---
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