summaryrefslogtreecommitdiff
path: root/drivers/accel
diff options
context:
space:
mode:
authorTomer Tayar <ttayar@habana.ai>2023-04-02 13:42:35 +0300
committerOded Gabbay <ogabbay@kernel.org>2023-04-08 10:44:23 +0300
commit56499c461589634f2c89ffbd9cfb78268191d349 (patch)
tree7b151e0ecba26407cd9d75be5d08cf167d02b32b /drivers/accel
parent31420f93b5c15746759cd87eaa0f572a7316ea46 (diff)
downloadlinux-56499c461589634f2c89ffbd9cfb78268191d349.tar.xz
accel/habanalabs: add missing error flow in hl_sysfs_init()
hl_sysfs_fini() is called only if hl_sysfs_init() completes successfully. Therefore if hl_sysfs_init() fails, need to remove any sysfs group that was added until that point. Signed-off-by: Tomer Tayar <ttayar@habana.ai> Reviewed-by: Oded Gabbay <ogabbay@kernel.org> Signed-off-by: Oded Gabbay <ogabbay@kernel.org>
Diffstat (limited to 'drivers/accel')
-rw-r--r--drivers/accel/habanalabs/common/sysfs.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/drivers/accel/habanalabs/common/sysfs.c b/drivers/accel/habanalabs/common/sysfs.c
index 735d8bed0066..01f89f029355 100644
--- a/drivers/accel/habanalabs/common/sysfs.c
+++ b/drivers/accel/habanalabs/common/sysfs.c
@@ -497,10 +497,14 @@ int hl_sysfs_init(struct hl_device *hdev)
if (rc) {
dev_err(hdev->dev,
"Failed to add groups to device, error %d\n", rc);
- return rc;
+ goto remove_groups;
}
return 0;
+
+remove_groups:
+ device_remove_groups(hdev->dev, hl_dev_attr_groups);
+ return rc;
}
void hl_sysfs_fini(struct hl_device *hdev)