linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] f2fs: don't kobject_put in the error case
@ 2025-01-31 22:24 Jaegeuk Kim
  2025-01-31 22:24 ` [PATCH 2/2] f2fs: introduce f2fs_base_attr for global sysfs entries Jaegeuk Kim
                   ` (3 more replies)
  0 siblings, 4 replies; 6+ messages in thread
From: Jaegeuk Kim @ 2025-01-31 22:24 UTC (permalink / raw)
  To: linux-kernel, linux-f2fs-devel; +Cc: Jaegeuk Kim

Fix a wrong kobject_put in the error path.

Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
---
 fs/f2fs/sysfs.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/fs/f2fs/sysfs.c b/fs/f2fs/sysfs.c
index d15c68b28952..001e97cd0a96 100644
--- a/fs/f2fs/sysfs.c
+++ b/fs/f2fs/sysfs.c
@@ -1605,7 +1605,7 @@ int __init f2fs_init_sysfs(void)
 	ret = kobject_init_and_add(&f2fs_feat, &f2fs_feat_ktype,
 				   NULL, "features");
 	if (ret)
-		goto put_kobject;
+		goto unregister_out;
 
 	f2fs_proc_root = proc_mkdir("fs/f2fs", NULL);
 	if (!f2fs_proc_root) {
@@ -1616,6 +1616,7 @@ int __init f2fs_init_sysfs(void)
 	return 0;
 put_kobject:
 	kobject_put(&f2fs_feat);
+unregister_out:
 	kset_unregister(&f2fs_kset);
 	return ret;
 }
-- 
2.48.1.362.g079036d154-goog


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 2/2] f2fs: introduce f2fs_base_attr for global sysfs entries
  2025-01-31 22:24 [PATCH 1/2] f2fs: don't kobject_put in the error case Jaegeuk Kim
@ 2025-01-31 22:24 ` Jaegeuk Kim
  2025-02-06  2:11   ` [f2fs-dev] " Chao Yu
  2025-02-02 14:58 ` [PATCH 1/2] f2fs: don't kobject_put in the error case Markus Elfring
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 6+ messages in thread
From: Jaegeuk Kim @ 2025-01-31 22:24 UTC (permalink / raw)
  To: linux-kernel, linux-f2fs-devel; +Cc: Jaegeuk Kim

In /sys/fs/f2fs/features, there's no f2fs_sb_info, so let's avoid to get
the pointer.

Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
---
 fs/f2fs/sysfs.c | 74 ++++++++++++++++++++++++++++++++++---------------
 1 file changed, 52 insertions(+), 22 deletions(-)

diff --git a/fs/f2fs/sysfs.c b/fs/f2fs/sysfs.c
index 001e97cd0a96..4bd7b17a20c8 100644
--- a/fs/f2fs/sysfs.c
+++ b/fs/f2fs/sysfs.c
@@ -61,6 +61,12 @@ struct f2fs_attr {
 	int id;
 };
 
+struct f2fs_base_attr {
+	struct attribute attr;
+	ssize_t (*show)(struct f2fs_base_attr *a, char *buf);
+	ssize_t (*store)(struct f2fs_base_attr *a, const char *buf, size_t len);
+};
+
 static ssize_t f2fs_sbi_show(struct f2fs_attr *a,
 			     struct f2fs_sb_info *sbi, char *buf);
 
@@ -862,6 +868,25 @@ static void f2fs_sb_release(struct kobject *kobj)
 	complete(&sbi->s_kobj_unregister);
 }
 
+static ssize_t f2fs_base_attr_show(struct kobject *kobj,
+				struct attribute *attr, char *buf)
+{
+	struct f2fs_base_attr *a = container_of(attr,
+				struct f2fs_base_attr, attr);
+
+	return a->show ? a->show(a, buf) : 0;
+}
+
+static ssize_t f2fs_base_attr_store(struct kobject *kobj,
+				struct attribute *attr,
+				const char *buf, size_t len)
+{
+	struct f2fs_base_attr *a = container_of(attr,
+				struct f2fs_base_attr, attr);
+
+	return a->store ? a->store(a, buf, len) : 0;
+}
+
 /*
  * Note that there are three feature list entries:
  * 1) /sys/fs/f2fs/features
@@ -880,14 +905,13 @@ static void f2fs_sb_release(struct kobject *kobj)
  *     please add new on-disk feature in this list only.
  *     - ref. F2FS_SB_FEATURE_RO_ATTR()
  */
-static ssize_t f2fs_feature_show(struct f2fs_attr *a,
-		struct f2fs_sb_info *sbi, char *buf)
+static ssize_t f2fs_feature_show(struct f2fs_base_attr *a, char *buf)
 {
 	return sysfs_emit(buf, "supported\n");
 }
 
 #define F2FS_FEATURE_RO_ATTR(_name)				\
-static struct f2fs_attr f2fs_attr_##_name = {			\
+static struct f2fs_base_attr f2fs_base_attr_##_name = {		\
 	.attr = {.name = __stringify(_name), .mode = 0444 },	\
 	.show	= f2fs_feature_show,				\
 }
@@ -1256,37 +1280,38 @@ static struct attribute *f2fs_attrs[] = {
 };
 ATTRIBUTE_GROUPS(f2fs);
 
+#define BASE_ATTR_LIST(name) (&f2fs_base_attr_##name.attr)
 static struct attribute *f2fs_feat_attrs[] = {
 #ifdef CONFIG_FS_ENCRYPTION
-	ATTR_LIST(encryption),
-	ATTR_LIST(test_dummy_encryption_v2),
+	BASE_ATTR_LIST(encryption),
+	BASE_ATTR_LIST(test_dummy_encryption_v2),
 #if IS_ENABLED(CONFIG_UNICODE)
-	ATTR_LIST(encrypted_casefold),
+	BASE_ATTR_LIST(encrypted_casefold),
 #endif
 #endif /* CONFIG_FS_ENCRYPTION */
 #ifdef CONFIG_BLK_DEV_ZONED
-	ATTR_LIST(block_zoned),
+	BASE_ATTR_LIST(block_zoned),
 #endif
-	ATTR_LIST(atomic_write),
-	ATTR_LIST(extra_attr),
-	ATTR_LIST(project_quota),
-	ATTR_LIST(inode_checksum),
-	ATTR_LIST(flexible_inline_xattr),
-	ATTR_LIST(quota_ino),
-	ATTR_LIST(inode_crtime),
-	ATTR_LIST(lost_found),
+	BASE_ATTR_LIST(atomic_write),
+	BASE_ATTR_LIST(extra_attr),
+	BASE_ATTR_LIST(project_quota),
+	BASE_ATTR_LIST(inode_checksum),
+	BASE_ATTR_LIST(flexible_inline_xattr),
+	BASE_ATTR_LIST(quota_ino),
+	BASE_ATTR_LIST(inode_crtime),
+	BASE_ATTR_LIST(lost_found),
 #ifdef CONFIG_FS_VERITY
-	ATTR_LIST(verity),
+	BASE_ATTR_LIST(verity),
 #endif
-	ATTR_LIST(sb_checksum),
+	BASE_ATTR_LIST(sb_checksum),
 #if IS_ENABLED(CONFIG_UNICODE)
-	ATTR_LIST(casefold),
+	BASE_ATTR_LIST(casefold),
 #endif
-	ATTR_LIST(readonly),
+	BASE_ATTR_LIST(readonly),
 #ifdef CONFIG_F2FS_FS_COMPRESSION
-	ATTR_LIST(compression),
+	BASE_ATTR_LIST(compression),
 #endif
-	ATTR_LIST(pin_file),
+	BASE_ATTR_LIST(pin_file),
 	NULL,
 };
 ATTRIBUTE_GROUPS(f2fs_feat);
@@ -1362,9 +1387,14 @@ static struct kset f2fs_kset = {
 	.kobj	= {.ktype = &f2fs_ktype},
 };
 
+static const struct sysfs_ops f2fs_feat_attr_ops = {
+	.show	= f2fs_base_attr_show,
+	.store	= f2fs_base_attr_store,
+};
+
 static const struct kobj_type f2fs_feat_ktype = {
 	.default_groups = f2fs_feat_groups,
-	.sysfs_ops	= &f2fs_attr_ops,
+	.sysfs_ops	= &f2fs_feat_attr_ops,
 };
 
 static struct kobject f2fs_feat = {
-- 
2.48.1.362.g079036d154-goog


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH 1/2] f2fs: don't kobject_put in the error case
  2025-01-31 22:24 [PATCH 1/2] f2fs: don't kobject_put in the error case Jaegeuk Kim
  2025-01-31 22:24 ` [PATCH 2/2] f2fs: introduce f2fs_base_attr for global sysfs entries Jaegeuk Kim
@ 2025-02-02 14:58 ` Markus Elfring
  2025-02-03 18:32 ` Jaegeuk Kim
  2025-02-06 18:40 ` [f2fs-dev] " patchwork-bot+f2fs
  3 siblings, 0 replies; 6+ messages in thread
From: Markus Elfring @ 2025-02-02 14:58 UTC (permalink / raw)
  To: Jaegeuk Kim, linux-f2fs-devel; +Cc: LKML

> Fix a wrong kobject_put in the error path.

* How do you think about to add any tags (like “Fixes” and “Cc”) accordingly?

* Will cover letters be usually helpful for such patch series?


Regards,
Markus

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 1/2] f2fs: don't kobject_put in the error case
  2025-01-31 22:24 [PATCH 1/2] f2fs: don't kobject_put in the error case Jaegeuk Kim
  2025-01-31 22:24 ` [PATCH 2/2] f2fs: introduce f2fs_base_attr for global sysfs entries Jaegeuk Kim
  2025-02-02 14:58 ` [PATCH 1/2] f2fs: don't kobject_put in the error case Markus Elfring
@ 2025-02-03 18:32 ` Jaegeuk Kim
  2025-02-06 18:40 ` [f2fs-dev] " patchwork-bot+f2fs
  3 siblings, 0 replies; 6+ messages in thread
From: Jaegeuk Kim @ 2025-02-03 18:32 UTC (permalink / raw)
  To: linux-kernel, linux-f2fs-devel

I checked this patch is wrong. Sorry for the noise.

On 01/31, Jaegeuk Kim wrote:
> Fix a wrong kobject_put in the error path.
> 
> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
> ---
>  fs/f2fs/sysfs.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/fs/f2fs/sysfs.c b/fs/f2fs/sysfs.c
> index d15c68b28952..001e97cd0a96 100644
> --- a/fs/f2fs/sysfs.c
> +++ b/fs/f2fs/sysfs.c
> @@ -1605,7 +1605,7 @@ int __init f2fs_init_sysfs(void)
>  	ret = kobject_init_and_add(&f2fs_feat, &f2fs_feat_ktype,
>  				   NULL, "features");
>  	if (ret)
> -		goto put_kobject;
> +		goto unregister_out;
>  
>  	f2fs_proc_root = proc_mkdir("fs/f2fs", NULL);
>  	if (!f2fs_proc_root) {
> @@ -1616,6 +1616,7 @@ int __init f2fs_init_sysfs(void)
>  	return 0;
>  put_kobject:
>  	kobject_put(&f2fs_feat);
> +unregister_out:
>  	kset_unregister(&f2fs_kset);
>  	return ret;
>  }
> -- 
> 2.48.1.362.g079036d154-goog

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [f2fs-dev] [PATCH 2/2] f2fs: introduce f2fs_base_attr for global sysfs entries
  2025-01-31 22:24 ` [PATCH 2/2] f2fs: introduce f2fs_base_attr for global sysfs entries Jaegeuk Kim
@ 2025-02-06  2:11   ` Chao Yu
  0 siblings, 0 replies; 6+ messages in thread
From: Chao Yu @ 2025-02-06  2:11 UTC (permalink / raw)
  To: Jaegeuk Kim, linux-kernel, linux-f2fs-devel; +Cc: chao

On 2/1/25 06:24, Jaegeuk Kim via Linux-f2fs-devel wrote:
> In /sys/fs/f2fs/features, there's no f2fs_sb_info, so let's avoid to get
> the pointer.
> 
> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>

Reviewed-by: Chao Yu <chao@kernel.org>

Thanks,

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [f2fs-dev] [PATCH 1/2] f2fs: don't kobject_put in the error case
  2025-01-31 22:24 [PATCH 1/2] f2fs: don't kobject_put in the error case Jaegeuk Kim
                   ` (2 preceding siblings ...)
  2025-02-03 18:32 ` Jaegeuk Kim
@ 2025-02-06 18:40 ` patchwork-bot+f2fs
  3 siblings, 0 replies; 6+ messages in thread
From: patchwork-bot+f2fs @ 2025-02-06 18:40 UTC (permalink / raw)
  To: Jaegeuk Kim; +Cc: linux-kernel, linux-f2fs-devel

Hello:

This series was applied to jaegeuk/f2fs.git (dev)
by Jaegeuk Kim <jaegeuk@kernel.org>:

On Fri, 31 Jan 2025 22:24:56 +0000 you wrote:
> Fix a wrong kobject_put in the error path.
> 
> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
> ---
>  fs/f2fs/sysfs.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)

Here is the summary with links:
  - [f2fs-dev,1/2] f2fs: don't kobject_put in the error case
    (no matching commit)
  - [f2fs-dev,2/2] f2fs: introduce f2fs_base_attr for global sysfs entries
    https://git.kernel.org/jaegeuk/f2fs/c/21925ede449e

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2025-02-06 18:40 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-01-31 22:24 [PATCH 1/2] f2fs: don't kobject_put in the error case Jaegeuk Kim
2025-01-31 22:24 ` [PATCH 2/2] f2fs: introduce f2fs_base_attr for global sysfs entries Jaegeuk Kim
2025-02-06  2:11   ` [f2fs-dev] " Chao Yu
2025-02-02 14:58 ` [PATCH 1/2] f2fs: don't kobject_put in the error case Markus Elfring
2025-02-03 18:32 ` Jaegeuk Kim
2025-02-06 18:40 ` [f2fs-dev] " patchwork-bot+f2fs

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).