Skip to content

Commit

Permalink
RDMA/rtrs-srv: Fix several issues in rtrs_srv_destroy_path_files
Browse files Browse the repository at this point in the history
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 <haris.iqbal@ionos.com>
Signed-off-by: Guoqing Jiang <guoqing.jiang@linux.dev>
Link: https://lore.kernel.org/r/20221117101945.6317-8-guoqing.jiang@linux.dev
Signed-off-by: Leon Romanovsky <leon@kernel.org>
  • Loading branch information
Guoqing Jiang authored and rleon committed Nov 17, 2022
1 parent 7526198 commit 6af4609
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions drivers/infiniband/ulp/rtrs/rtrs-srv-sysfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -304,12 +304,18 @@ int rtrs_srv_create_path_files(struct rtrs_srv_path *srv_path)

void rtrs_srv_destroy_path_files(struct rtrs_srv_path *srv_path)
{
if (srv_path->kobj.state_in_sysfs) {
if (srv_path->stats->kobj_stats.state_in_sysfs) {
sysfs_remove_group(&srv_path->stats->kobj_stats,
&rtrs_srv_stats_attr_group);
kobject_del(&srv_path->stats->kobj_stats);
kobject_put(&srv_path->stats->kobj_stats);
}

if (srv_path->kobj.state_in_sysfs) {
sysfs_remove_group(&srv_path->kobj, &rtrs_srv_path_attr_group);
kobject_del(&srv_path->kobj);
kobject_put(&srv_path->kobj);

rtrs_srv_destroy_once_sysfs_root_folders(srv_path);
}

rtrs_srv_destroy_once_sysfs_root_folders(srv_path);
}

0 comments on commit 6af4609

Please sign in to comment.