Re: [PATCH 14/33] vfs: Implement a filesystem superblock creation/configuration context [ver #11]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On (09/18/18 17:39), David Howells wrote:
[..]
> -static int legacy_init_fs_context(struct fs_context *fc, struct dentry *dentry)
> +int legacy_init_fs_context(struct fs_context *fc, struct dentry *dentry)
>  {
> +	switch (fc->purpose) {
> +	default:
> +		fc->fs_private = kzalloc(sizeof(struct legacy_fs_context),
> +					 GFP_KERNEL);
> +		if (!fc->fs_private)
> +			return -ENOMEM;

ops->reconfigure() invoked for FS_CONTEXT_FOR_UMOUNT or
FS_CONTEXT_FOR_EMERGENCY_RO will never access fc->fs_private?

> +		break;
>  
> -	fc->fs_private = kzalloc(sizeof(struct legacy_fs_context), GFP_KERNEL);
> -	if (!fc->fs_private)
> -		return -ENOMEM;
> +	case FS_CONTEXT_FOR_UMOUNT:
> +	case FS_CONTEXT_FOR_EMERGENCY_RO:
> +		break;
> +	}

So `fc' can either be zeroed-out, when it comes from fc = kzalloc(),
or contain some garbage otherwise. Would it make sense to zero-out `fc'
regardless of its origin?

>  	down_write(&sb->s_umount);
> -	if (!sb_rdonly(sb))
> -		/* Might want to call ->init_fs_context(). */
> -		ret = reconfigure_super(&fc);
> +	if (!sb_rdonly(sb)) {
> +		int ret;
> +
> +		if (fc.fs_type->init_fs_context)
> +			ret = fc.fs_type->init_fs_context(&fc, NULL);
> +		else
> +			ret = legacy_init_fs_context(&fc, NULL);
> +
> +		if (ret == 0) {
> +			ret = reconfigure_super(&fc);
> +			fc.ops->free(&fc);
			^^^^^^^
Is ops->free() always !NULL?

	-ss



[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [Samba]     [Device Mapper]     [CEPH Development]

  Powered by Linux