[Devel] [PATCH] sget(): handle failures of register_shrinker()

Kirill Tkhai ktkhai at virtuozzo.com
Mon Aug 27 14:27:07 MSK 2018


From: Al Viro <viro at zeniv.linux.org.uk>

ms commit 9ee332d99e4d

Signed-off-by: Al Viro <viro at zeniv.linux.org.uk>
[This may cause never shrinked SB and memory leak]
Signed-off-by: Kirill Tkhai <ktkhai at virtuozzo.com>
---
 fs/super.c |    6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/fs/super.c b/fs/super.c
index fcc01a129752..7e6352370a45 100644
--- a/fs/super.c
+++ b/fs/super.c
@@ -538,7 +538,11 @@ struct super_block *sget_userns(struct file_system_type *type,
 	hlist_add_head(&s->s_instances, &type->fs_supers);
 	spin_unlock(&sb_lock);
 	get_filesystem(type);
-	register_shrinker(&s->s_shrink);
+	err = register_shrinker(&s->s_shrink);
+	if (err) {
+		deactivate_locked_super(s);
+		s = ERR_PTR(err);
+	}
 	return s;
 }
 



More information about the Devel mailing list