Re: [patch 2/2] move init_ext4_proc() last and add cleanup call exit_ext4_proc()

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

 



On Tue, 2007-10-09 at 15:50 +1000, markn@xxxxxxxxxxx wrote:
> plain text document attachment (ext4-move-init_ext4_proc-add-
> cleanup.patch)
> The first problem that is addressed is that the addition of init_ext4_proc()
> means that the code doesn't clean up after itself on a failure of
> init_ext4_xattr(), and the second is that usually init_*_proc() should be
> the last thing called, so we move it to the end and add the cleanup call to
> exit_ext4_proc().
> 
> Signed-off-by: Mark Nelson <markn@xxxxxxxxxxx>
> ---
>  fs/ext4/super.c |    9 +++++----
>  1 file changed, 5 insertions(+), 4 deletions(-)
> 
> Index: ext4/fs/ext4/super.c
> ===================================================================
> --- ext4.orig/fs/ext4/super.c
> +++ ext4/fs/ext4/super.c
> @@ -2999,10 +2999,6 @@ static int __init init_ext4_fs(void)
>  {
>  	int err;
>  
> -	err = init_ext4_proc();
> -	if (err)
> -		return err;
> -
>  	err = init_ext4_xattr();
>  	if (err)
>  		return err;
> @@ -3012,7 +3008,12 @@ static int __init init_ext4_fs(void)
>  	err = register_filesystem(&ext4dev_fs_type);
>  	if (err)
>  		goto out;
> +	err = init_ext4_proc();
> +	if (err)
> +		goto out_proc;
>  	return 0;
> +out_proc:
> +	exit_ext4_proc();
>  out:
>  	destroy_inodecache();
>  out1:

Nope. You can not call exit_ext4_proc() if there is a failure
in init_ext4_proc(). If the kmem_cache_create() for ext4_pspace_cachep
fails, you would end up calling kmem_cache_destory(NULL).

The best way is to make init_ext4_proc() cleanup itself, in case
of an error. Hmm.. we are not handling proc_mkdir(EXT4_ROOT) 
failures.

Thanks,
Badari

-
To unsubscribe from this list: send the line "unsubscribe linux-ext4" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Reiser Filesystem Development]     [Ceph FS]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Linux FS]     [Yosemite National Park]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Device Mapper]     [Linux Media]

  Powered by Linux