RDMA/rtrs-srv: Fix several issues in rtrs_srv_destroy_path_files
authorGuoqing Jiang <guoqing.jiang@linux.dev>
Thu, 17 Nov 2022 10:19:44 +0000 (18:19 +0800)
committerLeon Romanovsky <leon@kernel.org>
Thu, 17 Nov 2022 11:47:28 +0000 (13:47 +0200)
commit6af4609c18b3aa69209d022b9c00e6db78c57ae5
tree7c096f09a5416315d167af1e7f79a27ac838afcc
parent7526198f27107278c600a3aee41f1a77ed84dd78
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 <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>
drivers/infiniband/ulp/rtrs/rtrs-srv-sysfs.c