Skip to content

Commit 6af4609

Browse files
Guoqing Jiangrleon
Guoqing Jiang
authored andcommitted
RDMA/rtrs-srv: Fix several issues in rtrs_srv_destroy_path_files
There are several issues in the function which is supposed to be paired with rtrs_srv_create_path_files. 1. rtrs_srv_stats_attr_group is not removed though it is created in rtrs_srv_create_stats_files. 2. it makes more sense to check kobj_stats.state_in_sysfs before destroy kobj_stats instead of rely on kobj.state_in_sysfs. 3. kobject_init_and_add is used for both kobjs (srv_path->kobj and srv_path->stats->kobj_stats), however we missed to call kobject_del for srv_path->kobj which was called in free_path. 4. rtrs_srv_destroy_once_sysfs_root_folders is independent of either kobj or kobj_stats. Acked-by: Md Haris Iqbal <[email protected]> Signed-off-by: Guoqing Jiang <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Leon Romanovsky <[email protected]>
1 parent 7526198 commit 6af4609

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

drivers/infiniband/ulp/rtrs/rtrs-srv-sysfs.c

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -304,12 +304,18 @@ int rtrs_srv_create_path_files(struct rtrs_srv_path *srv_path)
304304

305305
void rtrs_srv_destroy_path_files(struct rtrs_srv_path *srv_path)
306306
{
307-
if (srv_path->kobj.state_in_sysfs) {
307+
if (srv_path->stats->kobj_stats.state_in_sysfs) {
308+
sysfs_remove_group(&srv_path->stats->kobj_stats,
309+
&rtrs_srv_stats_attr_group);
308310
kobject_del(&srv_path->stats->kobj_stats);
309311
kobject_put(&srv_path->stats->kobj_stats);
312+
}
313+
314+
if (srv_path->kobj.state_in_sysfs) {
310315
sysfs_remove_group(&srv_path->kobj, &rtrs_srv_path_attr_group);
316+
kobject_del(&srv_path->kobj);
311317
kobject_put(&srv_path->kobj);
312-
313-
rtrs_srv_destroy_once_sysfs_root_folders(srv_path);
314318
}
319+
320+
rtrs_srv_destroy_once_sysfs_root_folders(srv_path);
315321
}

0 commit comments

Comments
 (0)