All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] f2fs: add sanity check for proc_mkdir
@ 2023-04-06 19:37 ` Yangtao Li via Linux-f2fs-devel
  0 siblings, 0 replies; 5+ messages in thread
From: Yangtao Li @ 2023-04-06 19:37 UTC (permalink / raw)
  To: Jaegeuk Kim, Chao Yu; +Cc: Yangtao Li, linux-f2fs-devel, linux-kernel

Return -ENOMEM when proc_mkdir failed.

Signed-off-by: Yangtao Li <frank.li@vivo.com>
---
 fs/f2fs/sysfs.c | 17 ++++++++++++-----
 1 file changed, 12 insertions(+), 5 deletions(-)

diff --git a/fs/f2fs/sysfs.c b/fs/f2fs/sysfs.c
index 3aad3500a701..dcd497e0920a 100644
--- a/fs/f2fs/sysfs.c
+++ b/fs/f2fs/sysfs.c
@@ -1385,12 +1385,19 @@ int __init f2fs_init_sysfs(void)
 
 	ret = kobject_init_and_add(&f2fs_feat, &f2fs_feat_ktype,
 				   NULL, "features");
-	if (ret) {
-		kobject_put(&f2fs_feat);
-		kset_unregister(&f2fs_kset);
-	} else {
-		f2fs_proc_root = proc_mkdir("fs/f2fs", NULL);
+	if (ret)
+		goto put_kobject;
+
+	f2fs_proc_root = proc_mkdir("fs/f2fs", NULL);
+	if (!f2fs_proc_root) {
+		ret = -ENOMEM;
+		goto put_kobject;
 	}
+
+	return 0;
+put_kobject:
+	kobject_put(&f2fs_feat);
+	kset_unregister(&f2fs_kset);
 	return ret;
 }
 
-- 
2.35.1


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

* [f2fs-dev] [PATCH] f2fs: add sanity check for proc_mkdir
@ 2023-04-06 19:37 ` Yangtao Li via Linux-f2fs-devel
  0 siblings, 0 replies; 5+ messages in thread
From: Yangtao Li via Linux-f2fs-devel @ 2023-04-06 19:37 UTC (permalink / raw)
  To: Jaegeuk Kim, Chao Yu; +Cc: linux-f2fs-devel, linux-kernel, Yangtao Li

Return -ENOMEM when proc_mkdir failed.

Signed-off-by: Yangtao Li <frank.li@vivo.com>
---
 fs/f2fs/sysfs.c | 17 ++++++++++++-----
 1 file changed, 12 insertions(+), 5 deletions(-)

diff --git a/fs/f2fs/sysfs.c b/fs/f2fs/sysfs.c
index 3aad3500a701..dcd497e0920a 100644
--- a/fs/f2fs/sysfs.c
+++ b/fs/f2fs/sysfs.c
@@ -1385,12 +1385,19 @@ int __init f2fs_init_sysfs(void)
 
 	ret = kobject_init_and_add(&f2fs_feat, &f2fs_feat_ktype,
 				   NULL, "features");
-	if (ret) {
-		kobject_put(&f2fs_feat);
-		kset_unregister(&f2fs_kset);
-	} else {
-		f2fs_proc_root = proc_mkdir("fs/f2fs", NULL);
+	if (ret)
+		goto put_kobject;
+
+	f2fs_proc_root = proc_mkdir("fs/f2fs", NULL);
+	if (!f2fs_proc_root) {
+		ret = -ENOMEM;
+		goto put_kobject;
 	}
+
+	return 0;
+put_kobject:
+	kobject_put(&f2fs_feat);
+	kset_unregister(&f2fs_kset);
 	return ret;
 }
 
-- 
2.35.1



_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

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

* Re: [PATCH] f2fs: add sanity check for proc_mkdir
  2023-04-06 19:37 ` [f2fs-dev] " Yangtao Li via Linux-f2fs-devel
  (?)
@ 2023-04-07  2:39 ` Bagas Sanjaya
  -1 siblings, 0 replies; 5+ messages in thread
From: Bagas Sanjaya @ 2023-04-07  2:39 UTC (permalink / raw)
  To: Yangtao Li, Jaegeuk Kim, Chao Yu; +Cc: linux-f2fs-devel, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 213 bytes --]

On Fri, Apr 07, 2023 at 03:37:16AM +0800, Yangtao Li wrote:
> Return -ENOMEM when proc_mkdir failed.

When out of memory (memory allocation fail)?

-- 
An old man doll... just what I always wanted! - Clara

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]

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

* Re: [PATCH] f2fs: add sanity check for proc_mkdir
  2023-04-06 19:37 ` [f2fs-dev] " Yangtao Li via Linux-f2fs-devel
@ 2023-04-23 16:03   ` Chao Yu
  -1 siblings, 0 replies; 5+ messages in thread
From: Chao Yu @ 2023-04-23 16:03 UTC (permalink / raw)
  To: Yangtao Li, Jaegeuk Kim; +Cc: linux-f2fs-devel, linux-kernel

On 2023/4/7 3:37, Yangtao Li wrote:
> Return -ENOMEM when proc_mkdir failed.
> 
> Signed-off-by: Yangtao Li <frank.li@vivo.com>
> ---
>   fs/f2fs/sysfs.c | 17 ++++++++++++-----
>   1 file changed, 12 insertions(+), 5 deletions(-)
> 
> diff --git a/fs/f2fs/sysfs.c b/fs/f2fs/sysfs.c
> index 3aad3500a701..dcd497e0920a 100644
> --- a/fs/f2fs/sysfs.c
> +++ b/fs/f2fs/sysfs.c
> @@ -1385,12 +1385,19 @@ int __init f2fs_init_sysfs(void)
>   
>   	ret = kobject_init_and_add(&f2fs_feat, &f2fs_feat_ktype,
>   				   NULL, "features");
> -	if (ret) {
> -		kobject_put(&f2fs_feat);
> -		kset_unregister(&f2fs_kset);
> -	} else {
> -		f2fs_proc_root = proc_mkdir("fs/f2fs", NULL);
> +	if (ret)
> +		goto put_kobject;
> +
> +	f2fs_proc_root = proc_mkdir("fs/f2fs", NULL);
> +	if (!f2fs_proc_root) {

How about removing below check for f2fs_proc_root in f2fs_register_sysfs()?

	if (f2fs_proc_root)
		sbi->s_proc = proc_mkdir(sb->s_id, f2fs_proc_root);

Thanks,

> +		ret = -ENOMEM;
> +		goto put_kobject;
>   	}
> +
> +	return 0;
> +put_kobject:
> +	kobject_put(&f2fs_feat);
> +	kset_unregister(&f2fs_kset);
>   	return ret;
>   }
>   

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

* Re: [f2fs-dev] [PATCH] f2fs: add sanity check for proc_mkdir
@ 2023-04-23 16:03   ` Chao Yu
  0 siblings, 0 replies; 5+ messages in thread
From: Chao Yu @ 2023-04-23 16:03 UTC (permalink / raw)
  To: Yangtao Li, Jaegeuk Kim; +Cc: linux-kernel, linux-f2fs-devel

On 2023/4/7 3:37, Yangtao Li wrote:
> Return -ENOMEM when proc_mkdir failed.
> 
> Signed-off-by: Yangtao Li <frank.li@vivo.com>
> ---
>   fs/f2fs/sysfs.c | 17 ++++++++++++-----
>   1 file changed, 12 insertions(+), 5 deletions(-)
> 
> diff --git a/fs/f2fs/sysfs.c b/fs/f2fs/sysfs.c
> index 3aad3500a701..dcd497e0920a 100644
> --- a/fs/f2fs/sysfs.c
> +++ b/fs/f2fs/sysfs.c
> @@ -1385,12 +1385,19 @@ int __init f2fs_init_sysfs(void)
>   
>   	ret = kobject_init_and_add(&f2fs_feat, &f2fs_feat_ktype,
>   				   NULL, "features");
> -	if (ret) {
> -		kobject_put(&f2fs_feat);
> -		kset_unregister(&f2fs_kset);
> -	} else {
> -		f2fs_proc_root = proc_mkdir("fs/f2fs", NULL);
> +	if (ret)
> +		goto put_kobject;
> +
> +	f2fs_proc_root = proc_mkdir("fs/f2fs", NULL);
> +	if (!f2fs_proc_root) {

How about removing below check for f2fs_proc_root in f2fs_register_sysfs()?

	if (f2fs_proc_root)
		sbi->s_proc = proc_mkdir(sb->s_id, f2fs_proc_root);

Thanks,

> +		ret = -ENOMEM;
> +		goto put_kobject;
>   	}
> +
> +	return 0;
> +put_kobject:
> +	kobject_put(&f2fs_feat);
> +	kset_unregister(&f2fs_kset);
>   	return ret;
>   }
>   


_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

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

end of thread, other threads:[~2023-04-23 16:03 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-04-06 19:37 [PATCH] f2fs: add sanity check for proc_mkdir Yangtao Li
2023-04-06 19:37 ` [f2fs-dev] " Yangtao Li via Linux-f2fs-devel
2023-04-07  2:39 ` Bagas Sanjaya
2023-04-23 16:03 ` Chao Yu
2023-04-23 16:03   ` [f2fs-dev] " Chao Yu

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.