vfs: set s_type in alloc_super()
PATCH 1/1 vfs: set s_type in alloc_super()
I see no reason to wait until after the "set" operation returns to set the s_type. We do call destroy_super() in some cases with that value unset. That seems to be OK in almost all cases, but we had a fire-drill recently with some RHEL-only patches that oopsed because the s_type was unset when destroy_super() got called.
Move the setting of the s_type into alloc_super() as a defensive coding measure.
--- fs/super.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/super.c +1 -1
@@ -218,6 +218,7 @@ static struct super_block *alloc_super(struct file_system_type *type, int flags) s->s_shrink.seeks =DEFAULT_SEEKS ; s->s_shrink.shrink = prune_super; s->s_shrink.batch =1024 ; + s->s_type = type; } out:return s;
@@ -487,7 +488,6 @@ retry:destroy_super (s);return ERR_PTR (err); } - s->s_type = type;strlcpy (s->s_id, type->name,sizeof (s->s_id));list_add_tail (&s->s_list, &super_blocks);hlist_add_head (&s->s_instances, &type->fs_supers);
Signature · 1 line
1.7.11.7
Al Viro
maintainerQuoted 8 lines · Jeff Layton
I see no reason to wait until after the "set" operation returns to set the
s_type. We do calldestroy_super()in some cases with that value unset. That seems to be OK in almost all cases, but we had a fire-drill recently with some RHEL-only patches that oopsed because thes_typewas unset whendestroy_super()got called.Move the setting of the
s_typeintoalloc_super()as a defensive coding measure.
NAK. If anything, I'm seriously tempted to zero ->s_type in
deactivate_locked_super() just before we do put_filesystem_type() and that reference becomes garbage.