sget(): handle failures of register_shrinker()

Submitted by Kirill Tkhai on Aug. 27, 2018, 11:27 a.m.

Details

Message ID 153536922517.31304.15385723882046727375.stgit@localhost.localdomain
State New
Series "sget(): handle failures of register_shrinker()"
Headers show

Commit Message

Kirill Tkhai Aug. 27, 2018, 11:27 a.m.
From: Al Viro <viro@zeniv.linux.org.uk>

ms commit 9ee332d99e4d

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

Patch hide | download patch | download mbox

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;
 }