Re: [PATCH 4.4 06/34] sget(): handle failures of register_shrinker()
From: Ben Hutchings
Date: Tue Mar 06 2018 - 21:17:01 EST
On Fri, 2018-03-02 at 09:51 +0100, Greg Kroah-Hartman wrote:
> 4.4-stable review patch.ÂÂIf anyone has any objections, please let me know.
>
> ------------------
>
> From: Al Viro <viro@xxxxxxxxxxxxxxxxxx>
>
>
> [ Upstream commit 9ee332d99e4d5a97548943b81c54668450ce641b ]
>
> Signed-off-by: Al Viro <viro@xxxxxxxxxxxxxxxxxx>
> Signed-off-by: Sasha Levin <alexander.levin@xxxxxxxxxxxxx>
> Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx>
> ---
> Âfs/super.c |ÂÂÂÂ6 +++++-
> Â1 file changed, 5 insertions(+), 1 deletion(-)
>
> --- a/fs/super.c
> +++ b/fs/super.c
> @@ -497,7 +497,11 @@ retry:
> Â 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);
But deactivate_locked_super() will call unregister_shrinker(), which
doesn't look safe if register_shrinker() failed.
Ben.
> + s = ERR_PTR(err);
> + }
> Â return s;
> Â}
> Â
>
>
>
--
Ben Hutchings
Software Developer, Codethink Ltd.