Skip to content

Commit 56499c4

Browse files
Tomer Tayarogabbay
authored andcommitted
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 <[email protected]> Reviewed-by: Oded Gabbay <[email protected]> Signed-off-by: Oded Gabbay <[email protected]>
1 parent 31420f9 commit 56499c4

File tree

1 file changed

+5
-1
lines changed
  • drivers/accel/habanalabs/common

1 file changed

+5
-1
lines changed

drivers/accel/habanalabs/common/sysfs.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -497,10 +497,14 @@ int hl_sysfs_init(struct hl_device *hdev)
497497
if (rc) {
498498
dev_err(hdev->dev,
499499
"Failed to add groups to device, error %d\n", rc);
500-
return rc;
500+
goto remove_groups;
501501
}
502502

503503
return 0;
504+
505+
remove_groups:
506+
device_remove_groups(hdev->dev, hl_dev_attr_groups);
507+
return rc;
504508
}
505509

506510
void hl_sysfs_fini(struct hl_device *hdev)

0 commit comments

Comments
 (0)