lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20230406093056.33916-3-frank.li@vivo.com>
Date:   Thu,  6 Apr 2023 17:30:56 +0800
From:   Yangtao Li <frank.li@...o.com>
To:     xiang@...nel.org, chao@...nel.org, huyue2@...lpad.com,
        jefflexu@...ux.alibaba.com, damien.lemoal@...nsource.wdc.com,
        naohiro.aota@....com, jth@...nel.org, gregkh@...uxfoundation.org,
        rafael@...nel.org
Cc:     linux-erofs@...ts.ozlabs.org, linux-kernel@...r.kernel.org,
        linux-fsdevel@...r.kernel.org, Yangtao Li <frank.li@...o.com>
Subject: [PATCH 3/3] zonefs: convert to use kobject_is_added()

Use kobject_is_added() instead of local `s_sysfs_registered` variables.
BTW kill kobject_del() directly, because kobject_put() actually covers
kobject removal automatically.

Signed-off-by: Yangtao Li <frank.li@...o.com>
---
 fs/zonefs/sysfs.c  | 11 +++++------
 fs/zonefs/zonefs.h |  1 -
 2 files changed, 5 insertions(+), 7 deletions(-)

diff --git a/fs/zonefs/sysfs.c b/fs/zonefs/sysfs.c
index 8ccb65c2b419..f0783bf7a25c 100644
--- a/fs/zonefs/sysfs.c
+++ b/fs/zonefs/sysfs.c
@@ -101,8 +101,6 @@ int zonefs_sysfs_register(struct super_block *sb)
 		return ret;
 	}
 
-	sbi->s_sysfs_registered = true;
-
 	return 0;
 }
 
@@ -110,12 +108,13 @@ void zonefs_sysfs_unregister(struct super_block *sb)
 {
 	struct zonefs_sb_info *sbi = ZONEFS_SB(sb);
 
-	if (!sbi || !sbi->s_sysfs_registered)
+	if (!sbi)
 		return;
 
-	kobject_del(&sbi->s_kobj);
-	kobject_put(&sbi->s_kobj);
-	wait_for_completion(&sbi->s_kobj_unregister);
+	if (kobject_is_added(&sbi->s_kobj)) {
+		kobject_put(&sbi->s_kobj);
+		wait_for_completion(&sbi->s_kobj_unregister);
+	}
 }
 
 int __init zonefs_sysfs_init(void)
diff --git a/fs/zonefs/zonefs.h b/fs/zonefs/zonefs.h
index 8175652241b5..4db0ea173220 100644
--- a/fs/zonefs/zonefs.h
+++ b/fs/zonefs/zonefs.h
@@ -238,7 +238,6 @@ struct zonefs_sb_info {
 	unsigned int		s_max_active_seq_files;
 	atomic_t		s_active_seq_files;
 
-	bool			s_sysfs_registered;
 	struct kobject		s_kobj;
 	struct completion	s_kobj_unregister;
 };
-- 
2.35.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ