Re: [PATCH] hugetlbfs: add err code in initializing module

From: Hillf Danton
Date: Thu Mar 22 2012 - 09:26:11 EST


On Thu, Mar 22, 2012 at 8:33 AM, Al Viro <viro@xxxxxxxxxxxxxxxxxx> wrote:
> On Sun, Mar 11, 2012 at 01:09:59PM +0800, Hillf Danton wrote:
>> Error code is added if fail to create inode kmem cache, and newly registered
>> hugetlb FS is unregistered if fail to mount, both for unlikely corner cases.
>>
>> --- a/fs/hugetlbfs/inode.c  ÂSun Mar 11 12:46:38 2012
>> +++ b/fs/hugetlbfs/inode.c  ÂSun Mar 11 12:49:28 2012
>> @@ -1000,6 +1000,7 @@ static int __init init_hugetlbfs_fs(void
>> Â Â Â hugetlbfs_inode_cachep = kmem_cache_create("hugetlbfs_inode_cache",
>> Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â sizeof(struct hugetlbfs_inode_info),
>> Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â 0, 0, init_once);
>> + Â Â error = -ENOMEM;
>> Â Â Â if (hugetlbfs_inode_cachep == NULL)
>> Â Â Â Â Â Â Â goto out2;
>>
>> @@ -1015,6 +1016,7 @@ static int __init init_hugetlbfs_fs(void
>> Â Â Â }
>>
>> Â Â Â error = PTR_ERR(vfsmount);
>> + Â Â unregister_filesystem(&hugetlbfs_fs_type);
>
> Bloody bad idea, that... ÂRealistically, the proper action on failure here
> (as well as in sock_init(), etc.) is panic(). ÂIf we fail to OOM that early,
> the box is doomed anyway.
>
> Note that unregister_filesystem() in module init is *always* wrong; it's not
> an issue here (it's done too early to care about and realistically the box
> is not going anywhere - it'll panic when attempt to exec /sbin/init fails,
> if not earlier), but it's a damn bad example.
>
Thanks for your review, Al.

Due to bad idea and bad example, please issue Nack, then the patch
that was not well prepared will be dropped.

-hd
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/