[RHEL7,COMMIT] ms/sget(): handle failures of register_shrinker()

Submitted by Konstantin Khorenko on Aug. 27, 2018, 3:05 p.m.

Details

Message ID 201808271505.w7RF5QIE025466@finist_ce7.work
State New
Series "sget(): handle failures of register_shrinker()"
Headers show

Commit Message

Konstantin Khorenko Aug. 27, 2018, 3:05 p.m.
The commit is pushed to "branch-rh7-3.10.0-862.11.6.vz7.71.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh7-3.10.0-862.11.6.vz7.71.4
------>
commit 5c99fa0a17a02bdb498c1d4d29f3eb09860a9427
Author: Al Viro <viro@zeniv.linux.org.uk>
Date:   Mon Aug 27 18:05:26 2018 +0300

    ms/sget(): handle failures of register_shrinker()
    
    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;
 }